@@ -319,15 +319,23 @@ Base.similar(A::OffsetArray, ::Type{T}, dims::Dims) where T =
319319 similar (parent (A), T, dims)
320320
321321"""
322- isonebased(ax:: AbstractUnitRange{<:Integer})
322+ isonebased(::Type{T}) where {T<: AbstractUnitRange{<:Integer}}
323323
324- Return whether `firstindex(ax)` is statically known to be `1`. Custom axis types may extend this method
325- to ensure that the axis offset is ignored, for example in `similar`.
324+ Return whether `first(ax::T)` is statically known to be `1` for any `ax` of type `T`
325+ (`false` by default).
326+ Custom axis types may extend this method to ensure that the axis offset is ignored,
327+ for example in `similar`. This may strip `OffsetArray` wrappers on occasion, or dispatch
328+ to `Base` methods for 1-based axes.
329+
330+ For axes that are essentially wrappers around another `AbstractUnitRange`,
331+ and share their indexing with their parents, one may forward the type of the
332+ parent range to `isonebased`.
326333"""
327- isonebased (_) = false
328- isonebased (:: Integer ) = true
329- isonebased (:: Base.OneTo ) = true
330- isonebased (r:: IIUR ) = isonebased (r. indices)
334+ isonebased (x) = isonebased (typeof (x))
335+ isonebased (:: Type ) = false
336+ isonebased (:: Type{<:Integer} ) = true
337+ isonebased (:: Type{<:Base.OneTo} ) = true
338+ isonebased (:: Type{IdentityUnitRange{T}} ) where {T} = isonebased (T)
331339
332340# Since the following is committing type-piracy, we provide an opt-out mechanism to the users
333341function Base. similar (A:: AbstractArray , :: Type{T} , shape:: Tuple{OffsetAxisKnownLength,Vararg{OffsetAxisKnownLength}} ) where T
0 commit comments