@@ -122,17 +122,6 @@ struct OffsetArray{T,N,AA<:AbstractArray{T,N}} <: AbstractArray{T,N}
122122end
123123
124124ArrayInterface. parent_type (:: Type{O} ) where {T,N,A<: AbstractArray{T,N} ,O<: OffsetArrays.OffsetArray{T,N,A} } = A
125- function _offset_axis_type (:: Type{T} , dim:: StaticInt{D} ) where {T,D}
126- OffsetArrays. IdOffsetRange{Int,ArrayInterface. axes_types (T, dim)}
127- end
128- function ArrayInterface. axes_types (:: Type{T} ) where {T<: OffsetArrays.OffsetArray }
129- ArrayInterface. Static. eachop_tuple (_offset_axis_type, Static. nstatic (Val (ndims (T))), ArrayInterface. parent_type (T))
130- end
131- @inline ArrayInterface. axes (A:: OffsetArrays.OffsetArray ) = Base. axes (A)
132- @inline _axes (A:: OffsetArrays.OffsetArray , dim:: Integer ) = Base. axes (A, dim)
133- @inline function ArrayInterface. axes (A:: OffsetArrays.OffsetArray{T,N} , :: StaticInt{M} ) where {T,M,N}
134- _axes (A, StaticInt {M} (), gt (StaticInt {M} (),StaticInt {N} ()))
135- end
136125
137126"""
138127 OffsetVector(v, index)
@@ -299,10 +288,20 @@ Base.parent(A::OffsetArray) = A.parent
299288# Base.Broadcast.BroadcastStyle(::Type{<:OffsetArray{<:Any, <:Any, AA}}) where AA = Base.Broadcast.BroadcastStyle(AA)
300289
301290@inline Base. size (A:: OffsetArray ) = size (parent (A))
291+ @inline Base. size (A:: OffsetArray , dim) = size (parent (A), ArrayInterface. to_dims (A, dim))
302292
303- @inline Base. axes (A:: OffsetArray ) = map (IdOffsetRange, axes (parent (A)), A. offsets)
304- @inline Base. axes (A:: OffsetArray , d) = d <= ndims (A) ? IdOffsetRange (axes (parent (A), d), A. offsets[d]) : IdOffsetRange (axes (parent (A), d))
293+ @inline Base. axes (A:: OffsetArray ) = map (IdOffsetRange, ArrayInterface. axes (parent (A)), A. offsets)
294+ Base. axes (A:: OffsetArray , d) = axes (A, ArrayInterface. to_dims (A, d))
295+ @inline function Base. axes (A:: OffsetArray , d:: Union{Int,StaticInt} )
296+ d <= ndims (A) ? IdOffsetRange (axes (parent (A), d), A. offsets[d]) : IdOffsetRange (axes (parent (A), d))
297+ end
305298@inline Base. axes1 (A:: OffsetArray{T,0} ) where {T} = IdOffsetRange (axes (parent (A), 1 )) # we only need to specialize this one
299+ function _offset_axis_type (:: Type{T} , dim:: StaticInt{D} ) where {T,D}
300+ OffsetArrays. IdOffsetRange{Int,ArrayInterface. axes_types (T, dim)}
301+ end
302+ function ArrayInterface. axes_types (:: Type{T} ) where {T<: OffsetArrays.OffsetArray }
303+ Static. eachop_tuple (_offset_axis_type, Static. nstatic (Val (ndims (T))), ArrayInterface. parent_type (T))
304+ end
306305
307306# Issue 128
308307# See https://github.com/JuliaLang/julia/issues/37274 for the issue reported in Base
0 commit comments