11using OffsetArrays
22using Test
33using DelimitedFiles
4+ using OffsetArrays: IdentityUnitRange
45
56@test isempty (detect_ambiguities (OffsetArrays, Base, Core))
67
@@ -42,8 +43,8 @@ y = OffsetArray(r, r)
4243y = OffsetArray (r, (r,))
4344@test axes (y) == (r,)
4445
45- y = OffsetArray {Float32} (undef, (Base . Slice (- 1 : 1 ),))
46- @test axes (y) === (Base . Slice (- 1 : 1 ),)
46+ y = OffsetArray {Float32} (undef, (IdentityUnitRange (- 1 : 1 ),))
47+ @test axes (y) === (IdentityUnitRange (- 1 : 1 ),)
4748
4849A0 = [1 3 ; 2 4 ]
4950A = OffsetArray (A0, (- 1 ,2 )) # IndexLinear
@@ -104,21 +105,21 @@ Ac[0,3,1] = 11
104105@test_throws BoundsError S[CartesianIndex (1 ,1 ),0 ]
105106@test_throws BoundsError S[CartesianIndex (1 ,1 ),2 ]
106107@test eachindex (A) == 1 : 4
107- @test eachindex (S) == CartesianIndices (Base . Slice .((0 : 1 ,3 : 4 )))
108+ @test eachindex (S) == CartesianIndices (IdentityUnitRange .((0 : 1 ,3 : 4 )))
108109
109110# view
110111S = view (A, :, 3 )
111112@test S == OffsetArray ([1 ,2 ], (A. offsets[1 ],))
112113@test S[0 ] == 1
113114@test S[1 ] == 2
114115@test_throws BoundsError S[2 ]
115- @test axes (S) === (Base . Slice (0 : 1 ),)
116+ @test axes (S) === (IdentityUnitRange (0 : 1 ),)
116117S = view (A, 0 , :)
117118@test S == OffsetArray ([1 ,3 ], (A. offsets[2 ],))
118119@test S[3 ] == 1
119120@test S[4 ] == 3
120121@test_throws BoundsError S[1 ]
121- @test axes (S) === (Base . Slice (3 : 4 ),)
122+ @test axes (S) === (IdentityUnitRange (3 : 4 ),)
122123S = view (A, 0 : 0 , 4 )
123124@test S == [3 ]
124125@test S[1 ] == 3
@@ -137,7 +138,7 @@ S = view(A, :, :)
137138@test S[0 ,4 ] == S[3 ] == 3
138139@test S[1 ,4 ] == S[4 ] == 4
139140@test_throws BoundsError S[1 ,1 ]
140- @test axes (S) === Base . Slice .((0 : 1 , 3 : 4 ))
141+ @test axes (S) === IdentityUnitRange .((0 : 1 , 3 : 4 ))
141142
142143# iteration
143144let a
@@ -178,10 +179,10 @@ B = similar(A, (3,4))
178179@test axes (B) === (Base. OneTo (3 ), Base. OneTo (4 ))
179180B = similar (A, (- 3 : 3 ,1 : 4 ))
180181@test isa (B, OffsetArray{Int,2 })
181- @test axes (B) === Base . Slice .((- 3 : 3 , 1 : 4 ))
182+ @test axes (B) === IdentityUnitRange .((- 3 : 3 , 1 : 4 ))
182183B = similar (parent (A), (- 3 : 3 ,1 : 4 ))
183184@test isa (B, OffsetArray{Int,2 })
184- @test axes (B) === Base . Slice .((- 3 : 3 , 1 : 4 ))
185+ @test axes (B) === IdentityUnitRange .((- 3 : 3 , 1 : 4 ))
185186@test isa ([x for x in [1 ,2 ,3 ]], Vector{Int})
186187@test similar (Array{Int}, (0 : 0 , 0 : 0 )) isa OffsetArray{Int, 2 }
187188@test similar (Array{Int}, (1 , 1 )) isa Matrix{Int}
@@ -191,13 +192,13 @@ B = similar(parent(A), (-3:3,1:4))
191192B = reshape (A0, - 10 : - 9 , 9 : 10 )
192193@test isa (B, OffsetArray{Int,2 })
193194@test parent (B) === A0
194- @test axes (B) == Base . Slice .((- 10 : - 9 , 9 : 10 ))
195+ @test axes (B) == IdentityUnitRange .((- 10 : - 9 , 9 : 10 ))
195196B = reshape (A, - 10 : - 9 , 9 : 10 )
196197@test isa (B, OffsetArray{Int,2 })
197198@test pointer (parent (B)) === pointer (A0)
198- @test axes (B) == Base . Slice .((- 10 : - 9 , 9 : 10 ))
199+ @test axes (B) == IdentityUnitRange .((- 10 : - 9 , 9 : 10 ))
199200b = reshape (A, - 7 : - 4 )
200- @test axes (b) == (Base . Slice (- 7 : - 4 ),)
201+ @test axes (b) == (IdentityUnitRange (- 7 : - 4 ),)
201202@test isa (parent (b), Vector{Int})
202203@test pointer (parent (b)) === pointer (parent (A))
203204@test parent (b) == A0[:]
@@ -206,27 +207,27 @@ a = OffsetArray(rand(3,3,3), -1:1, 0:2, 3:5)
206207b = reshape (a, Val (2 ))
207208@test isa (b, OffsetArray{Float64,2 })
208209@test pointer (parent (b)) === pointer (parent (a))
209- @test axes (b) == Base . Slice .((- 1 : 1 , 1 : 9 ))
210+ @test axes (b) == IdentityUnitRange .((- 1 : 1 , 1 : 9 ))
210211b = reshape (a, Val (4 ))
211212@test isa (b, OffsetArray{Float64,4 })
212213@test pointer (parent (b)) === pointer (parent (a))
213- @test axes (b) == (axes (a)... , Base . Slice (1 : 1 ))
214+ @test axes (b) == (axes (a)... , IdentityUnitRange (1 : 1 ))
214215
215216# Indexing with OffsetArray axes
216217i1 = OffsetArray ([2 ,1 ], (- 5 ,))
217218i1 = OffsetArray ([2 ,1 ], - 5 )
218219b = A0[i1, 1 ]
219- @test axes (b) === (Base . Slice (- 4 : - 3 ),)
220+ @test axes (b) === (IdentityUnitRange (- 4 : - 3 ),)
220221@test b[- 4 ] == 2
221222@test b[- 3 ] == 1
222223b = A0[1 ,i1]
223- @test axes (b) === (Base . Slice (- 4 : - 3 ),)
224+ @test axes (b) === (IdentityUnitRange (- 4 : - 3 ),)
224225@test b[- 4 ] == 3
225226@test b[- 3 ] == 1
226227v = view (A0, i1, 1 )
227- @test axes (v) === (Base . Slice (- 4 : - 3 ),)
228+ @test axes (v) === (IdentityUnitRange (- 4 : - 3 ),)
228229v = view (A0, 1 : 1 , i1)
229- @test axes (v) === (Base. OneTo (1 ), Base . Slice (- 4 : - 3 ))
230+ @test axes (v) === (Base. OneTo (1 ), IdentityUnitRange (- 4 : - 3 ))
230231
231232# logical indexing
232233@test A[A .> 2 ] == [3 ,4 ]
0 commit comments