@@ -88,7 +88,7 @@ Returns the axis associated with each dimension of `A` or dimension `dim`.
88
88
exception of a handful of types replace `Base.OneTo{Int}` with `ArrayInterface.SOneTo`. For
89
89
example, the axis along the first dimension of `Transpose{T,<:AbstractVector{T}}` and
90
90
`Adjoint{T,<:AbstractVector{T}}` can be represented by `SOneTo(1)`. Similarly,
91
- `Base.ReinterpretArray`'s first axis may be statically sized.
91
+ `Base.ReinterpretArray`'s first axis may be statically sized.
92
92
"""
93
93
@inline axes (A) = Base. axes (A)
94
94
axes (A:: ReshapedArray ) = Base. axes (A)
112
112
return getfield (axes (A), Int (dim))
113
113
end
114
114
end
115
- axes (A:: SubArray , dim) = Base. axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
115
+
116
+ @inline function axes (A:: SubArray , dim:: Integer )
117
+ if dim > ndims (A)
118
+ return OneTo (1 )
119
+ else
120
+ return axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
121
+ end
122
+ end
123
+ @inline function axes (A:: SubArray , :: StaticInt{dim} ) where {dim}
124
+ if dim > ndims (A)
125
+ return SOneTo {1} ()
126
+ else
127
+ return axes (getindex (A. indices, to_parent_dims (A, to_dims (A, dim))), 1 )
128
+ end
129
+ end
130
+
116
131
if isdefined (Base, :ReshapedReinterpretArray )
117
132
function axes_types (:: Type{A} ) where {T,N,S,A<: Base.ReshapedReinterpretArray{T,N,S} }
118
133
if sizeof (S) > sizeof (T)
0 commit comments