@@ -81,7 +81,7 @@ for i = 1:9 @test A_3_3[i] == i end
8181@test_throws BoundsError A[CartesianIndex (1 ,1 )]
8282@test_throws BoundsError S[CartesianIndex (1 ,1 )]
8383@test eachindex (A) == 1 : 4
84- @test eachindex (S) == CartesianIndices (axes (S)) == CartesianIndices (map (Base. Slice , (0 : 1 ,3 : 4 )))
84+ @test eachindex (S) == CartesianIndices (axes (S)) == CartesianIndices (map (Base. IdentityUnitRange , (0 : 1 ,3 : 4 )))
8585
8686# LinearIndices
8787# issue 27986
@@ -122,13 +122,13 @@ S = view(A, :, 3)
122122@test S[0 ] == 1
123123@test S[1 ] == 2
124124@test_throws BoundsError S[2 ]
125- @test axes (S) === (Base. Slice (0 : 1 ),)
125+ @test axes (S) === (Base. IdentityUnitRange (0 : 1 ),)
126126S = view (A, 0 , :)
127127@test S == OffsetArray ([1 ,3 ], (A. offsets[2 ],))
128128@test S[3 ] == 1
129129@test S[4 ] == 3
130130@test_throws BoundsError S[1 ]
131- @test axes (S) === (Base. Slice (3 : 4 ),)
131+ @test axes (S) === (Base. IdentityUnitRange (3 : 4 ),)
132132S = view (A, 0 : 0 , 4 )
133133@test S == [3 ]
134134@test S[1 ] == 3
@@ -147,17 +147,17 @@ S = view(A, :, :)
147147@test S[0 ,4 ] == S[3 ] == 3
148148@test S[1 ,4 ] == S[4 ] == 4
149149@test_throws BoundsError S[1 ,1 ]
150- @test axes (S) === Base. Slice .((0 : 1 , 3 : 4 ))
150+ @test axes (S) === Base. IdentityUnitRange .((0 : 1 , 3 : 4 ))
151151# https://github.com/JuliaArrays/OffsetArrays.jl/issues/27
152152g = OffsetArray (Vector (- 2 : 3 ), (- 3 ,))
153153gv = view (g, - 1 : 2 )
154154@test axes (gv, 1 ) === Base. OneTo (4 )
155155@test collect (gv) == - 1 : 2
156156gv = view (g, OffsetArray (- 1 : 2 , (- 2 ,)))
157- @test axes (gv, 1 ) === Base. Slice (- 1 : 2 )
157+ @test axes (gv, 1 ) === Base. IdentityUnitRange (- 1 : 2 )
158158@test collect (gv) == - 1 : 2
159159gv = view (g, OffsetArray (- 1 : 2 , (- 1 ,)))
160- @test axes (gv, 1 ) === Base. Slice (0 : 3 )
160+ @test axes (gv, 1 ) === Base. IdentityUnitRange (0 : 3 )
161161@test collect (gv) == - 1 : 2
162162
163163# iteration
@@ -234,26 +234,26 @@ B = similar(A, (3,4))
234234@test axes (B) === (Base. OneTo (3 ), Base. OneTo (4 ))
235235B = similar (A, (- 3 : 3 ,1 : 4 ))
236236@test isa (B, OffsetArray{Int,2 })
237- @test axes (B) === Base. Slice .((- 3 : 3 , 1 : 4 ))
237+ @test axes (B) === Base. IdentityUnitRange .((- 3 : 3 , 1 : 4 ))
238238B = similar (parent (A), (- 3 : 3 ,1 : 4 ))
239239@test isa (B, OffsetArray{Int,2 })
240- @test axes (B) === Base. Slice .((- 3 : 3 , 1 : 4 ))
240+ @test axes (B) === Base. IdentityUnitRange .((- 3 : 3 , 1 : 4 ))
241241
242242# Indexing with OffsetArray indices
243243i1 = OffsetArray ([2 ,1 ], (- 5 ,))
244244i1 = OffsetArray ([2 ,1 ], - 5 )
245245b = A0[i1, 1 ]
246- @test axes (b) === (Base. Slice (- 4 : - 3 ),)
246+ @test axes (b) === (Base. IdentityUnitRange (- 4 : - 3 ),)
247247@test b[- 4 ] == 2
248248@test b[- 3 ] == 1
249249b = A0[1 ,i1]
250- @test axes (b) === (Base. Slice (- 4 : - 3 ),)
250+ @test axes (b) === (Base. IdentityUnitRange (- 4 : - 3 ),)
251251@test b[- 4 ] == 3
252252@test b[- 3 ] == 1
253253v = view (A0, i1, 1 )
254- @test axes (v) === (Base. Slice (- 4 : - 3 ),)
254+ @test axes (v) === (Base. IdentityUnitRange (- 4 : - 3 ),)
255255v = view (A0, 1 : 1 , i1)
256- @test axes (v) === (Base. OneTo (1 ), Base. Slice (- 4 : - 3 ))
256+ @test axes (v) === (Base. OneTo (1 ), Base. IdentityUnitRange (- 4 : - 3 ))
257257
258258# copyto! and fill!
259259a = OffsetArray {Int} (undef, (- 3 : - 1 ,))
@@ -340,7 +340,7 @@ a = OffsetArray(a0, (-1,2,3,4,5))
340340v = OffsetArray (v0, (- 3 ,))
341341@test lastindex (v) == 1
342342@test v ≈ v
343- @test axes (v' ) === (Base. OneTo (1 ),Base. Slice (- 2 : 1 ))
343+ @test axes (v' ) === (Base. OneTo (1 ),Base. IdentityUnitRange (- 2 : 1 ))
344344@test parent (v) == collect (v)
345345rv = reverse (v)
346346@test axes (rv) == axes (v)
@@ -356,7 +356,7 @@ A = OffsetArray(rand(4,4), (-3,5))
356356@test lastindex (A, 1 ) == 1
357357@test lastindex (A, 2 ) == 9
358358@test A ≈ A
359- @test axes (A' ) === Base. Slice .((6 : 9 , - 2 : 1 ))
359+ @test axes (A' ) === Base. IdentityUnitRange .((6 : 9 , - 2 : 1 ))
360360@test parent (copy (A' )) == copy (parent (A)' )
361361@test collect (A) == parent (A)
362362@test maximum (A) == maximum (parent (A))
498498 A = OffsetArray (reshape (16 : - 1 : 1 , (4 , 4 )), (- 3 ,5 ))
499499 @test maximum (A, dims= 1 ) == OffsetArray (maximum (parent (A), dims= 1 ), A. offsets)
500500end
501+
502+ @testset " in-place reductions with mismatched dimensionalities" begin
503+ B = OffsetArray (reshape (1 : 24 , 4 , 3 , 2 ), - 5 , 6 , - 7 )
504+ for R in (fill (0 , - 4 : - 1 ), fill (0 , - 4 : - 1 , 7 : 7 ), fill (0 , - 4 : - 1 , 7 : 7 , - 6 : - 6 ))
505+ @test @inferred (maximum! (R, B)) == reshape (maximum (B, dims= (2 ,3 )), axes (R)) == reshape (21 : 24 , axes (R))
506+ @test @allocated (maximum! (R, B)) <= 400
507+ @test @inferred (minimum! (R, B)) == reshape (minimum (B, dims= (2 ,3 )), axes (R)) == reshape (1 : 4 , axes (R))
508+ @test @allocated (minimum! (R, B)) <= 400
509+ end
510+ for R in (fill (0 , - 4 : - 4 , 7 : 9 ), fill (0 , - 4 : - 4 , 7 : 9 , - 6 : - 6 ))
511+ @test @inferred (maximum! (R, B)) == reshape (maximum (B, dims= (1 ,3 )), axes (R)) == reshape (16 : 4 : 24 , axes (R))
512+ @test @allocated (maximum! (R, B)) <= 400
513+ @test @inferred (minimum! (R, B)) == reshape (minimum (B, dims= (1 ,3 )), axes (R)) == reshape (1 : 4 : 9 , axes (R))
514+ @test @allocated (minimum! (R, B)) <= 400
515+ end
516+ @test_throws DimensionMismatch maximum! (fill (0 , - 4 : - 1 , 7 : 7 , - 6 : - 6 , 1 : 1 ), B)
517+ @test_throws DimensionMismatch minimum! (fill (0 , - 4 : - 1 , 7 : 7 , - 6 : - 6 , 1 : 1 ), B)
518+ @test_throws DimensionMismatch maximum! (fill (0 , - 4 : - 4 , 7 : 9 , - 6 : - 6 , 1 : 1 ), B)
519+ @test_throws DimensionMismatch minimum! (fill (0 , - 4 : - 4 , 7 : 9 , - 6 : - 6 , 1 : 1 ), B)
520+ @test_throws DimensionMismatch maximum! (fill (0 , - 4 : - 4 , 7 : 7 , - 6 : - 5 , 1 : 1 ), B)
521+ @test_throws DimensionMismatch minimum! (fill (0 , - 4 : - 4 , 7 : 7 , - 6 : - 5 , 1 : 1 ), B)
522+ end
0 commit comments