@@ -14,7 +14,6 @@ include("utils.jl")
14
14
15
15
# Technically we know the length of CartesianIndices but we need to convert it first, so here we
16
16
# don't put it in OffsetAxisKnownLength.
17
- # TODO : add CartesianIndices to OffsetAxisKnownLength
18
17
const OffsetAxisKnownLength = Union{Integer, AbstractUnitRange, IdOffsetRange}
19
18
const OffsetAxis = Union{OffsetAxisKnownLength, CartesianIndices, Colon}
20
19
const ArrayInitializer = Union{UndefInitializer, Missing, Nothing}
@@ -115,8 +114,7 @@ for FT in (:OffsetArray, :OffsetVector, :OffsetMatrix)
115
114
indsN = _uncolonindices (A, _expandCartesianIndices (inds))
116
115
$ FT (A, indsN)
117
116
end
118
- @eval $ FT (A:: AbstractArray{T} , inds:: Vararg{OffsetAxis,N} ) where {T, N} = $ FT (A, inds)
119
- @eval $ FT (A:: AbstractArray , inds:: CartesianIndices ) = $ FT (A, convert (Tuple{Vararg{AbstractUnitRange{Int}}}, inds))
117
+ @eval $ FT (A:: AbstractArray{T} , inds... ) where {T, N} = $ FT (A, inds)
120
118
end
121
119
122
120
# array initialization
@@ -130,15 +128,15 @@ function OffsetArray{T, N}(init::ArrayInitializer, inds::NTuple{NT, Union{Offset
130
128
length (indsN) == N || throw (DimensionMismatch (" The number of offsets $(length (indsN)) should equal ndims(A) = $N " ))
131
129
OffsetArray {T, N} (init, indsN)
132
130
end
133
- OffsetArray {T,N} (init:: ArrayInitializer , inds:: Union{OffsetAxisKnownLength, CartesianIndices} ...) where {T,N} = OffsetArray {T,N} (init, inds)
131
+ OffsetArray {T,N} (init:: ArrayInitializer , inds... ) where {T,N} = OffsetArray {T,N} (init, inds)
134
132
135
133
OffsetArray {T} (init:: ArrayInitializer , inds:: NTuple{N, OffsetAxisKnownLength} ) where {T,N} = OffsetArray {T,N} (init, inds)
136
134
function OffsetArray {T} (init:: ArrayInitializer , inds:: NTuple{N, Union{OffsetAxisKnownLength, CartesianIndices}} ) where {T, N}
137
135
# N is probably not the actual dimension of the array; CartesianIndices might contain multiple dimensions
138
136
indsN = _expandCartesianIndices (inds)
139
137
OffsetArray {T, length(indsN)} (init, indsN)
140
138
end
141
- OffsetArray {T} (init:: ArrayInitializer , inds:: Union{OffsetAxisKnownLength, CartesianIndices} ...) where {T} = OffsetArray {T} (init, inds)
139
+ OffsetArray {T} (init:: ArrayInitializer , inds... ) where {T} = OffsetArray {T} (init, inds)
142
140
143
141
Base. IndexStyle (:: Type{OA} ) where {OA<: OffsetArray } = IndexStyle (parenttype (OA))
144
142
parenttype (:: Type{OffsetArray{T,N,AA}} ) where {T,N,AA} = AA
0 commit comments