@@ -84,11 +84,24 @@ OffsetArray{T}(init::ArrayInitializer, inds::Vararg{AbstractUnitRange,N}) where
84
84
OffsetVector (A:: AbstractVector , offset) = OffsetArray (A, offset)
85
85
OffsetVector {T} (init:: ArrayInitializer , inds:: AbstractUnitRange ) where {T} = OffsetArray {T} (init, inds)
86
86
87
- # # The next two are necessary for ambiguity resolution. Really, the
88
- # # second method should not be necessary.
89
- # OffsetArray(A::AbstractArray{T,0}, inds::Tuple{}) where {T} = OffsetArray{T,0,typeof(A)}(A, ())
90
- # OffsetArray(A::AbstractArray{T,N}, inds::Tuple{}) where {T,N} = error("this should never be called")
87
+ """
88
+ OffsetArray(A, indices...)
89
+
90
+ Return an `AbstractArray` that shares element type and size with the first argument, but
91
+ used the given `indices`, which are checked for compatible size.
92
+
93
+ # Example
91
94
95
+ ```jldoctest
96
+ julia> A = OffsetArray(reshape(1:6, 2, 3), 0:1, -1:1)
97
+ OffsetArray(reshape(::UnitRange{Int64}, 2, 3), 0:1, -1:1) with eltype Int64 with indices 0:1×-1:1:
98
+ 1 3 5
99
+ 2 4 6
100
+
101
+ julia> A[0, 1]
102
+ 5
103
+ ```
104
+ """
92
105
function OffsetArray (A:: AbstractArray{T,N} , inds:: NTuple{N,AbstractUnitRange} ) where {T,N}
93
106
axparent = axes (A)
94
107
lA = map (length, axparent)
0 commit comments