@@ -207,22 +207,22 @@ end
207
207
@testset " Range Interface" begin
208
208
@testset " Range Constructors" begin
209
209
@test @inferred (StaticInt (1 ): StaticInt (10 )) == 1 : 10
210
- @test @inferred (StaticInt (1 ): StaticInt (2 ): StaticInt (10 )) == 1 : 2 : 10
210
+ @test @inferred (StaticInt (1 ): StaticInt (2 ): StaticInt (10 )) == 1 : 2 : 10
211
211
@test @inferred (1 : StaticInt (2 ): StaticInt (10 )) == 1 : 2 : 10
212
212
@test @inferred (StaticInt (1 ): StaticInt (2 ): 10 ) == 1 : 2 : 10
213
- @test @inferred (StaticInt (1 ): 2 : StaticInt (10 )) == 1 : 2 : 10
213
+ @test @inferred (StaticInt (1 ): 2 : StaticInt (10 )) == 1 : 2 : 10
214
214
@test @inferred (1 : 2 : StaticInt (10 )) == 1 : 2 : 10
215
215
@test @inferred (1 : StaticInt (2 ): 10 ) == 1 : 2 : 10
216
- @test @inferred (StaticInt (1 ): 2 : 10 ) == 1 : 2 : 10
217
- @test @inferred (StaticInt (1 ): UInt (10 )) === StaticInt (1 ): 10
216
+ @test @inferred (StaticInt (1 ): 2 : 10 ) == 1 : 2 : 10
217
+ @test @inferred (StaticInt (1 ): UInt (10 )) === StaticInt (1 ): 10
218
218
@test @inferred (UInt (1 ): StaticInt (1 ): StaticInt (10 )) === 1 : StaticInt (10 )
219
219
@test @inferred (ArrayInterface. OptionallyStaticUnitRange {Int,Int} (1 : 10 )) == 1 : 10
220
220
@test @inferred (ArrayInterface. OptionallyStaticUnitRange (1 : 10 )) == 1 : 10
221
221
222
222
@inferred (ArrayInterface. OptionallyStaticUnitRange (1 : 10 ))
223
223
224
- @test @inferred (ArrayInterface. OptionallyStaticStepRange (StaticInt (1 ), 1 , UInt (10 ))) == StaticInt (1 ): 1 : 10
225
- @test @inferred (ArrayInterface. OptionallyStaticStepRange (UInt (1 ), 1 , StaticInt (10 ))) == StaticInt (1 ): 1 : 10
224
+ @test @inferred (ArrayInterface. OptionallyStaticStepRange (StaticInt (1 ), 1 , UInt (10 ))) == StaticInt (1 ): 1 : 10
225
+ @test @inferred (ArrayInterface. OptionallyStaticStepRange (UInt (1 ), 1 , StaticInt (10 ))) == StaticInt (1 ): 1 : 10
226
226
@test @inferred (ArrayInterface. OptionallyStaticStepRange (1 : 10 )) == 1 : 1 : 10
227
227
228
228
@test_throws ArgumentError ArrayInterface. OptionallyStaticUnitRange (1 : 2 : 10 )
@@ -331,7 +331,6 @@ using OffsetArrays
331
331
@test @inferred (ArrayInterface. defines_strides (D1))
332
332
@test ! @inferred (ArrayInterface. defines_strides (view (A, :, [1 ,2 ],1 )))
333
333
@test @inferred (ArrayInterface. defines_strides (DenseWrapper{Int,2 ,Matrix{Int}}))
334
-
335
334
@test @inferred (device (A)) === ArrayInterface. CPUPointer ()
336
335
@test @inferred (device (B)) === ArrayInterface. CPUIndex ()
337
336
@test @inferred (device (- 1 : 19 )) === ArrayInterface. CPUIndex ()
@@ -372,7 +371,7 @@ using OffsetArrays
372
371
@test @inferred (contiguous_axis (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
373
372
@test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
374
373
@test @inferred (contiguous_axis (view (DummyZeros (3 ,4 ), 1 , :)' )) === nothing
375
-
374
+
376
375
@test @inferred (ArrayInterface. contiguous_axis_indicator (@SArray (zeros (2 ,2 ,2 )))) == (true ,false ,false )
377
376
@test @inferred (ArrayInterface. contiguous_axis_indicator (A)) == (true ,false ,false )
378
377
@test @inferred (ArrayInterface. contiguous_axis_indicator (B)) == (true ,false ,false )
@@ -424,7 +423,7 @@ using OffsetArrays
424
423
@test @inferred (stride_rank (PermutedDimsArray (DummyZeros (3 ,4 ), (2 , 1 )))) === nothing
425
424
@test @inferred (stride_rank (view (DummyZeros (3 ,4 ), 1 , :))) === nothing
426
425
427
-
426
+
428
427
#=
429
428
@btime ArrayInterface.is_column_major($(PermutedDimsArray(A,(3,1,2))))
430
429
0.047 ns (0 allocations: 0 bytes)
@@ -494,11 +493,11 @@ using OffsetArrays
494
493
@test @inferred (ArrayInterface. defines_strides (C1))
495
494
@test @inferred (ArrayInterface. defines_strides (C2))
496
495
@test @inferred (ArrayInterface. defines_strides (C3))
497
-
496
+
498
497
@test @inferred (device (C1)) === ArrayInterface. CPUPointer ()
499
498
@test @inferred (device (C2)) === ArrayInterface. CPUPointer ()
500
499
@test @inferred (device (C3)) === ArrayInterface. CPUPointer ()
501
-
500
+
502
501
@test @inferred (contiguous_batch_size (C1)) === ArrayInterface. StaticInt (0 )
503
502
@test @inferred (contiguous_batch_size (C2)) === ArrayInterface. StaticInt (0 )
504
503
@test @inferred (contiguous_batch_size (C3)) === ArrayInterface. StaticInt (0 )
@@ -510,7 +509,7 @@ using OffsetArrays
510
509
@test @inferred (contiguous_axis (C1)) === StaticInt (1 )
511
510
@test @inferred (contiguous_axis (C2)) === StaticInt (0 )
512
511
@test @inferred (contiguous_axis (C3)) === StaticInt (2 )
513
-
512
+
514
513
@test @inferred (ArrayInterface. contiguous_axis_indicator (C1)) == (true ,false ,false ,false )
515
514
@test @inferred (ArrayInterface. contiguous_axis_indicator (C2)) == (false ,false )
516
515
@test @inferred (ArrayInterface. contiguous_axis_indicator (C3)) == (false ,true )
675
674
colormat = reinterpret (reshape, Float64, colors)
676
675
@test @inferred (ArrayInterface. strides (colormat)) === (StaticInt (1 ), StaticInt (3 ))
677
676
@test @inferred (ArrayInterface. dense_dims (colormat)) === (True (),True ())
678
- @test @inferred (ArrayInterface. dense_dims (view (colormat,:,4 ))) === (True (),)
677
+ @test @inferred (ArrayInterface. dense_dims (view (colormat,:,4 ))) === (True (),)
679
678
@test @inferred (ArrayInterface. dense_dims (view (colormat,:,4 : 7 ))) === (True (),True ())
680
679
@test @inferred (ArrayInterface. dense_dims (view (colormat,2 : 3 ,:))) === (True (),False ())
681
680
702
701
@test @inferred (ArrayInterface. strides (Ac2r)) === (StaticInt (1 ), StaticInt (2 ), 10 )
703
702
Ac2r_static = reinterpret (reshape, Float64, view (@MMatrix (rand (ComplexF64, 5 , 7 )), 2 : 4 , 3 : 6 ));
704
703
@test @inferred (ArrayInterface. strides (Ac2r_static)) === (StaticInt (1 ), StaticInt (2 ), StaticInt (10 ))
705
-
704
+
706
705
Ac2t = reinterpret (reshape, Tuple{Float64,Float64}, view (rand (ComplexF64, 5 , 7 ), 2 : 4 , 3 : 6 ));
707
706
@test @inferred (ArrayInterface. strides (Ac2t)) === (StaticInt (1 ), 5 )
708
707
Ac2t_static = reinterpret (reshape, Tuple{Float64,Float64}, view (@MMatrix (rand (ComplexF64, 5 , 7 )), 2 : 4 , 3 : 6 ));
711
710
end
712
711
end
713
712
713
+ @testset " Reshaped views" begin
714
+ # See
715
+ # https://github.com/JuliaArrays/ArrayInterface.jl/issues/160
716
+ # https://github.com/JuliaArrays/ArrayInterface.jl/issues/157
717
+ u_base = randn (10 , 10 )
718
+ u_view = view (u_base, 3 , :)
719
+ u_reshaped_view1 = reshape (u_view, 1 , :)
720
+ u_reshaped_view2 = reshape (u_view, 2 , :)
721
+
722
+ @test @inferred (ArrayInterface. defines_strides (u_base))
723
+ @test @inferred (ArrayInterface. defines_strides (u_view))
724
+ @test @inferred (ArrayInterface. defines_strides (u_reshaped_view1))
725
+ @test @inferred (ArrayInterface. defines_strides (u_reshaped_view2))
726
+
727
+ @test @inferred (ArrayInterface. strides (u_base)) == (StaticInt (1 ), 10 )
728
+ @test @inferred (ArrayInterface. strides (u_view)) == (10 ,)
729
+ @test @inferred (ArrayInterface. strides (u_reshaped_view1)) == (10 , 10 )
730
+ @test @inferred (ArrayInterface. strides (u_reshaped_view2)) == (10 , 20 )
731
+ end
732
+
714
733
@test ArrayInterface. can_avx (ArrayInterface. can_avx) == false
715
734
716
735
@testset " can_change_size" begin
842
861
@test @inferred (is_lazy_conjugate (d)) == false
843
862
e = permutedims (d)
844
863
@test @inferred (is_lazy_conjugate (e)) == false
845
-
864
+
846
865
@test @inferred (is_lazy_conjugate ([1 ,2 ,3 ]' )) == false # We don't care about conj on `<:Real`
847
866
end
0 commit comments