@@ -133,15 +133,13 @@ Base.fill(x, inds::Tuple{UnitRange,Vararg{UnitRange}}) =
133
133
# ## Low-level utilities ###
134
134
135
135
# Computing a shifted index (subtracting the offset)
136
- @inline offset (offsets:: NTuple{N,Int} , inds:: NTuple{N,Int} ) where {N} = _offset ((), offsets, inds)
137
- _offset (out, :: Tuple{} , :: Tuple{} ) = out
138
- @inline _offset (out, offsets, inds) =
139
- _offset ((out... , inds[1 ]- offsets[1 ]), Base. tail (offsets), Base. tail (inds))
136
+ @inline offset (offsets:: NTuple{N,Int} , inds:: NTuple{N,Int} ) where {N} =
137
+ (inds[1 ]- offsets[1 ], offset (Base. tail (offsets), Base. tail (inds))... )
138
+ offset (:: Tuple{} , :: Tuple{} ) = ()
140
139
141
140
# Support trailing 1s
142
141
@inline offset (offsets:: Tuple{Vararg{Int}} , inds:: Tuple{Vararg{Int}} ) =
143
142
(offset (offsets, Base. front (inds))... , inds[end ])
144
- offset (offsets:: Tuple{} , inds:: Tuple{} ) = ()
145
143
offset (offsets:: Tuple{Vararg{Int}} , inds:: Tuple{} ) = error (" inds cannot be shorter than offsets" )
146
144
147
145
indexoffset (r:: AbstractRange ) = first (r) - 1
221
219
@inline unsafe_getindex (a:: OffsetSubArray , I:: Union{Integer,CartesianIndex} ...) = unsafe_getindex (a, Base. IteratorsMD. flatten (I)... )
222
220
@inline unsafe_setindex! (a:: OffsetSubArray , val, I:: Union{Integer,CartesianIndex} ...) = unsafe_setindex! (a, val, Base. IteratorsMD. flatten (I)... )
223
221
222
+ if VERSION >= v " 0.7.0-DEV.1790"
223
+ function Base. showarg (io:: IO , a:: OffsetArray , toplevel)
224
+ print (io, " OffsetArray(" )
225
+ Base. showarg (io, parent (a), false )
226
+ print (io, " , " )
227
+ printindices (io, indices (a)... )
228
+ print (io, ' )' )
229
+ toplevel && print (io, " with eltype " , eltype (a))
230
+ end
231
+ printindices (io:: IO , ind1, inds... ) =
232
+ (print (io, ind1, " , " ); printindices (io, inds... ))
233
+ printindices (io:: IO , ind1) = print (io, ind1)
234
+ end
235
+
224
236
end # module
0 commit comments