Skip to content

Commit d0bc252

Browse files
get rid of extra naming
1 parent bf5416d commit d0bc252

File tree

8 files changed

+55
-64
lines changed

8 files changed

+55
-64
lines changed

docs/make.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
using ArrayInterface
2-
using Pkg
3-
4-
function dev_subpkg(subpkg)
5-
subpkg_path = joinpath(dirname(@__DIR__), "lib", subpkg)
6-
Pkg.develop(PackageSpec(path=subpkg_path))
7-
end
8-
dev_subpkg("ArrayInterfaceCore")
9-
10-
using ArrayInterfaceCore
1+
using StaticArrayInterface
112
using Documenter
123

134
makedocs(;
14-
modules=[ArrayInterface, ArrayInterfaceCore],
15-
sitename="ArrayInterface",
5+
modules=[StaticArrayInterface],
6+
sitename="StaticArrayInterface.jl",
167
pages=[
17-
"Home" => "index.md",
8+
"StaticArrayInterface.jl: Static Compile-Time Enforced Array Interface Functionality" => "index.md",
189
"API" => "api.md"
1910
]
2011
)

src/StaticArrayInterface.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ import Compat
4747
Tuple{X.parameters..., Y.parameters...}
4848
end
4949

50-
Base.size(A::AbstractArray2) = map(Int, ArrayInterface.static_size(A))
51-
Base.size(A::AbstractArray2, dim) = Int(ArrayInterface.static_size(A, dim))
50+
Base.size(A::AbstractArray2) = map(Int, static_size(A))
51+
Base.size(A::AbstractArray2, dim) = Int(static_size(A, dim))
5252

5353
function Base.axes(A::AbstractArray2)
54-
is_forwarding_wrapper(A) && return ArrayInterface.static_axes(parent(A))
54+
is_forwarding_wrapper(A) && return static_axes(parent(A))
5555
throw(ArgumentError("Subtypes of `AbstractArray2` must define an axes method"))
5656
end
5757
function Base.axes(A::AbstractArray2, dim::Union{Symbol, StaticSymbol})
5858
static_axes(A, to_dims(A, dim))
5959
end
6060

6161
function Base.strides(A::AbstractArray2)
62-
defines_strides(A) && return map(Int, ArrayInterface.static_strides(A))
62+
defines_strides(A) && return map(Int, static_strides(A))
6363
throw(MethodError(Base.strides, (A,)))
6464
end
65-
Base.strides(A::AbstractArray2, dim) = Int(ArrayInterface.static_strides(A, dim))
65+
Base.strides(A::AbstractArray2, dim) = Int(static_strides(A, dim))
6666

6767
function Base.IndexStyle(::Type{T}) where {T <: AbstractArray2}
6868
is_forwarding_wrapper(T) ? IndexStyle(parent_type(T)) : IndexCartesian()
@@ -121,14 +121,14 @@ Examples
121121
1 - 1im
122122
1 + 1im
123123
124-
julia> ArrayInterface.is_lazy_conjugate(a)
124+
julia> is_lazy_conjugate(a)
125125
True()
126126
127127
julia> b = a'
128128
1×2 adjoint(transpose(adjoint(::Vector{Complex{Int64}}))) with eltype Complex{Int64}:
129129
1+1im 1-1im
130130
131-
julia> ArrayInterface.is_lazy_conjugate(b)
131+
julia> is_lazy_conjugate(b)
132132
False()
133133
134134
"""

src/axes.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ end
102102
static_axes(A, dim) -> AbstractUnitRange{Int}
103103
104104
Returns the axis associated with each dimension of `A` or dimension `dim`.
105-
`ArrayInterface.static_axes(::AbstractArray)` behaves nearly identical to `Base.axes` with the
106-
exception of a handful of types replace `Base.OneTo{Int}` with `ArrayInterface.SOneTo`. For
105+
`static_axes(::AbstractArray)` behaves nearly identical to `Base.axes` with the
106+
exception of a handful of types replace `Base.OneTo{Int}` with `SOneTo`. For
107107
example, the axis along the first dimension of `Transpose{T,<:AbstractVector{T}}` and
108108
`Adjoint{T,<:AbstractVector{T}}` can be represented by `SOneTo(1)`. Similarly,
109109
`Base.ReinterpretArray`'s first axis may be statically sized.
@@ -173,20 +173,20 @@ Base.IndexStyle(T::Type{<:LazyAxis}) = IndexStyle(parent_type(T))
173173
function Static.OptionallyStaticUnitRange(x::LazyAxis)
174174
OptionallyStaticUnitRange(static_first(x), static_last(x))
175175
end
176-
ArrayInterface.can_change_size(@nospecialize T::Type{<:LazyAxis}) = can_change_size(fieldtype(T, :parent))
176+
can_change_size(@nospecialize T::Type{<:LazyAxis}) = can_change_size(fieldtype(T, :parent))
177177

178-
ArrayInterface.known_first(::Type{<:LazyAxis{N,P}}) where {N,P} = known_offsets(P, static(N))
179-
ArrayInterface.known_first(::Type{<:LazyAxis{:,P}}) where {P} = 1
178+
known_first(::Type{<:LazyAxis{N,P}}) where {N,P} = known_offsets(P, static(N))
179+
known_first(::Type{<:LazyAxis{:,P}}) where {P} = 1
180180
@inline function Base.first(x::LazyAxis{N})::Int where {N}
181-
if ArrayInterface.known_first(x) === nothing
181+
if known_first(x) === nothing
182182
return Int(offsets(getfield(x, :parent), StaticInt(N)))
183183
else
184184
return Int(known_first(x))
185185
end
186186
end
187187
@inline Base.first(x::LazyAxis{:})::Int = Int(offset1(getfield(x, :parent)))
188-
ArrayInterface.known_last(::Type{LazyAxis{N,P}}) where {N,P} = known_last(axes_types(P, static(N)))
189-
ArrayInterface.known_last(::Type{LazyAxis{:,P}}) where {P} = known_length(P)
188+
known_last(::Type{LazyAxis{N,P}}) where {N,P} = known_last(axes_types(P, static(N)))
189+
known_last(::Type{LazyAxis{:,P}}) where {P} = known_length(P)
190190
Base.last(x::LazyAxis) = _last(known_last(x), x)
191191
_last(::Nothing, x::LazyAxis{:}) = lastindex(getfield(x, :parent))
192192
_last(::Nothing, x::LazyAxis{N}) where {N} = lastindex(getfield(x, :parent), N)

src/broadcast.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ to both `x` and `y` unless one has a length of `1`, in which case the longest ax
1111
equal to the output.
1212
1313
```julia
14-
julia> ArrayInterface.broadcast_axis(1:10, 1:10)
14+
julia> broadcast_axis(1:10, 1:10)
1515
16-
julia> ArrayInterface.broadcast_axis(1:10, 1)
16+
julia> broadcast_axis(1:10, 1)
1717
1:10
1818
1919
```

src/indexing.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
"""
3-
ArrayInterface.static_to_indices(A, I::Tuple) -> Tuple
3+
static_to_indices(A, I::Tuple) -> Tuple
44
55
Converts the tuple of indexing arguments, `I`, into an appropriate form for indexing into `A`.
66
Typically, each index should be an `Int`, `StaticInt`, a collection with values of `Int`, or a collection with values of `CartesianIndex`
@@ -29,14 +29,14 @@ This implementation differs from that of `Base.to_indices` in the following ways
2929
1.105 μs (12 allocations: 672 bytes)
3030
(1, 1, 2, 1, 1, 2, 1, 1, 2, 1)
3131
32-
julia> @btime ArrayInterface.static_to_indices(\$x, \$inds2)
32+
julia> @btime static_to_indices(\$x, \$inds2)
3333
0.041 ns (0 allocations: 0 bytes)
3434
(1, 1, 2, 1, 1, 2, 1, 1, 2, 1)
3535
3636
julia> @btime Base.to_indices(\$x, \$inds3);
3737
340.629 ns (14 allocations: 768 bytes)
3838
39-
julia> @btime ArrayInterface.static_to_indices(\$x, \$inds3);
39+
julia> @btime static_to_indices(\$x, \$inds3);
4040
11.614 ns (0 allocations: 0 bytes)
4141
4242
```
@@ -80,41 +80,41 @@ end
8080
end
8181

8282
"""
83-
ArrayInterface.to_index([::IndexStyle, ]axis, arg) -> index
83+
to_index([::IndexStyle, ]axis, arg) -> index
8484
85-
Convert the argument `arg` that was originally passed to `ArrayInterface.static_getindex` for the
85+
Convert the argument `arg` that was originally passed to `static_getindex` for the
8686
dimension corresponding to `axis` into a form for native indexing (`Int`, Vector{Int}, etc.).
8787
88-
`ArrayInterface.to_index` supports passing a function as an index. This function-index is
88+
`to_index` supports passing a function as an index. This function-index is
8989
transformed into a proper index.
9090
9191
```julia
9292
julia> using ArrayInterface, Static
9393
94-
julia> ArrayInterface.to_index(static(1):static(10), 5)
94+
julia> to_index(static(1):static(10), 5)
9595
5
9696
97-
julia> ArrayInterface.to_index(static(1):static(10), <(5))
97+
julia> to_index(static(1):static(10), <(5))
9898
static(1):4
9999
100-
julia> ArrayInterface.to_index(static(1):static(10), <=(5))
100+
julia> to_index(static(1):static(10), <=(5))
101101
static(1):5
102102
103-
julia> ArrayInterface.to_index(static(1):static(10), >(5))
103+
julia> to_index(static(1):static(10), >(5))
104104
6:static(10)
105105
106-
julia> ArrayInterface.to_index(static(1):static(10), >=(5))
106+
julia> to_index(static(1):static(10), >=(5))
107107
5:static(10)
108108
109109
```
110110
111111
Use of a function-index helps ensure that indices are inbounds
112112
113113
```julia
114-
julia> ArrayInterface.to_index(static(1):static(10), <(12))
114+
julia> to_index(static(1):static(10), <(12))
115115
static(1):10
116116
117-
julia> ArrayInterface.to_index(static(1):static(10), >(-1))
117+
julia> to_index(static(1):static(10), >(-1))
118118
1:static(10)
119119
```
120120
@@ -259,10 +259,10 @@ end
259259
to_axis(S::IndexLinear, axis, inds) = StaticInt(1):static_length(inds)
260260

261261
"""
262-
ArrayInterface.static_getindex(A, args...)
262+
static_getindex(A, args...)
263263
264264
Retrieve the value(s) stored at the given key or index within a collection. Creating
265-
another instance of `ArrayInterface.static_getindex` should only be done by overloading `A`.
265+
another instance of `static_getindex` should only be done by overloading `A`.
266266
Changing indexing based on a given argument from `args` should be done through,
267267
[`to_index`](@ref), or [`to_axis`](@ref).
268268
"""
@@ -380,7 +380,7 @@ _known_first_isone(ind) = known_first(ind) !== nothing && isone(known_first(ind)
380380
end
381381

382382
"""
383-
ArrayInterface.setindex!(A, args...)
383+
setindex!(A, args...)
384384
385385
Store the given values at the given key or index within a collection.
386386
"""
@@ -446,10 +446,10 @@ If `first` of an instance of type `T` is known at compile time, return it.
446446
Otherwise, return `nothing`.
447447
448448
```julia
449-
julia> ArrayInterface.known_first(typeof(1:4))
449+
julia> known_first(typeof(1:4))
450450
nothing
451451
452-
julia> ArrayInterface.known_first(typeof(Base.OneTo(4)))
452+
julia> known_first(typeof(Base.OneTo(4)))
453453
1
454454
```
455455
"""
@@ -469,10 +469,10 @@ If `last` of an instance of type `T` is known at compile time, return it.
469469
Otherwise, return `nothing`.
470470
471471
```julia
472-
julia> ArrayInterface.known_last(typeof(1:4))
472+
julia> known_last(typeof(1:4))
473473
nothing
474474
475-
julia> ArrayInterface.known_first(typeof(static(1):static(4)))
475+
julia> known_first(typeof(static(1):static(4)))
476476
4
477477
478478
```
@@ -490,10 +490,10 @@ If `step` of an instance of type `T` is known at compile time, return it.
490490
Otherwise, return `nothing`.
491491
492492
```julia
493-
julia> StaticArrayInterface.known_step(typeof(1:2:8))
493+
julia> known_step(typeof(1:2:8))
494494
nothing
495495
496-
julia> StaticArrayInterface.known_step(typeof(1:4))
496+
julia> known_step(typeof(1:4))
497497
1
498498
499499
```

src/ranges.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
ArrayInterface.known_first(::Type{<:OptionallyStaticUnitRange{StaticInt{F}}}) where {F} = F::Int
3-
ArrayInterface.known_first(::Type{<:OptionallyStaticStepRange{StaticInt{F}}}) where {F} = F::Int
2+
known_first(::Type{<:OptionallyStaticUnitRange{StaticInt{F}}}) where {F} = F::Int
3+
known_first(::Type{<:OptionallyStaticStepRange{StaticInt{F}}}) where {F} = F::Int
44

5-
ArrayInterface.known_step(::Type{<:OptionallyStaticStepRange{<:Any,StaticInt{S}}}) where {S} = S::Int
5+
known_step(::Type{<:OptionallyStaticStepRange{<:Any,StaticInt{S}}}) where {S} = S::Int
66

7-
ArrayInterface.known_last(::Type{<:OptionallyStaticUnitRange{<:Any,StaticInt{L}}}) where {L} = L::Int
8-
ArrayInterface.known_last(::Type{<:OptionallyStaticStepRange{<:Any,<:Any,StaticInt{L}}}) where {L} = L::Int
7+
known_last(::Type{<:OptionallyStaticUnitRange{<:Any,StaticInt{L}}}) where {L} = L::Int
8+
known_last(::Type{<:OptionallyStaticStepRange{<:Any,<:Any,StaticInt{L}}}) where {L} = L::Int
99

1010
"""
1111
indices(x, dim) -> AbstractUnitRange{Int}

src/size.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
66
Returns the size of each dimension of `A` or along dimension `dim` of `A`. If the size of
77
any axes are known at compile time, these should be returned as `Static` numbers. Otherwise,
8-
`ArrayInterface.static_size(A)` is identical to `Base.size(A)`
8+
`static_size(A)` is identical to `Base.size(A)`
99
1010
```julia
1111
julia> using StaticArrays, ArrayInterface
1212
1313
julia> A = @SMatrix rand(3,4);
1414
15-
julia> ArrayInterface.static_size(A)
15+
julia> static_size(A)
1616
(static(3), static(4))
1717
```
1818
"""
@@ -188,15 +188,15 @@ known_size(T::Type, dim::IntType) = ndims(T) < dim ? 1 : known_size(T)[dim]
188188
static_length(A) -> Union{Int,StaticInt}
189189
190190
Returns the length of `A`. If the length is known at compile time, it is
191-
returned as `Static` number. Otherwise, `ArrayInterface.static_length(A)` is identical
191+
returned as `Static` number. Otherwise, `static_length(A)` is identical
192192
to `Base.length(A)`.
193193
194194
```julia
195195
julia> using StaticArrays, ArrayInterface
196196
197197
julia> A = @SMatrix rand(3,4);
198198
199-
julia> ArrayInterface.static_length(A)
199+
julia> static_length(A)
200200
static(12)
201201
```
202202
"""

src/stridelayout.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ these should be returned as `Static` numbers. For example:
485485
```julia
486486
julia> A = rand(3,4);
487487
488-
julia> ArrayInterface.static_strides(A)
488+
julia> static_strides(A)
489489
(static(1), 3)
490490
```
491491
@@ -494,7 +494,7 @@ Additionally, the behavior differs from `Base.strides` for adjoint vectors:
494494
```julia
495495
julia> x = rand(5);
496496
497-
julia> ArrayInterface.static_strides(x')
497+
julia> static_strides(x')
498498
(static(1), static(1))
499499
```
500500
@@ -519,7 +519,7 @@ _is_column_dense(::A) where {A<:AbstractArray} =
519519
defines_strides(A) &&
520520
(ndims(A) == 0 || Bool(is_dense(A)) && Bool(is_column_major(A)))
521521

522-
# Fixes the example of https://github.com/JuliaArrays/ArrayInterface.jl/issues/160
522+
# Fixes the example of https://github.com/JuliaArrays/jl/issues/160
523523
function static_strides(A::ReshapedArray)
524524
if _is_column_dense(parent(A))
525525
return size_to_strides(static_size(A), One())

0 commit comments

Comments
 (0)