|
1 | 1 |
|
2 | 2 | using HybridArrays, ArrayInterface, Test, StaticArrays |
| 3 | +using ArrayInterface: StaticInt |
3 | 4 |
|
4 | 5 | @testset "ArrayInterface compatibility" begin |
5 | 6 | M = HybridMatrix{2, StaticArrays.Dynamic()}([1 2; 4 5]) |
| 7 | + MV = HybridMatrix{3, StaticArrays.Dynamic()}(view(randn(10, 10), 1:2:5, 1:3:12)) |
6 | 8 | @test ArrayInterface.ismutable(M) |
7 | 9 | @test ArrayInterface.can_setindex(M) |
8 | 10 | @test ArrayInterface.parent_type(M) === Matrix{Int} |
9 | 11 | @test ArrayInterface.restructure(M, [2, 4, 6, 8]) == HybridMatrix{2, StaticArrays.Dynamic()}([2 6; 4 8]) |
10 | 12 | @test isa(ArrayInterface.restructure(M, [2, 4, 6, 8]), HybridMatrix{2, StaticArrays.Dynamic()}) |
| 13 | + |
| 14 | + M2 = HybridArray{Tuple{2, 3, StaticArrays.Dynamic(), StaticArrays.Dynamic()}}(randn(2, 3, 5, 7)) |
| 15 | + @test (@inferred ArrayInterface.strides(M2)) === (StaticInt(1), StaticInt(2), StaticInt(6), 30) |
| 16 | + @test (@inferred ArrayInterface.strides(MV)) === (2, 30) |
| 17 | + @test (@inferred ArrayInterface.size(M2)) === (StaticInt(2), StaticInt(3), 5, 7) |
| 18 | + |
| 19 | + @test ArrayInterface.contiguous_axis(typeof(M2)) === ArrayInterface.contiguous_axis(typeof(M2.data)) |
| 20 | + @test ArrayInterface.contiguous_batch_size(typeof(M2)) === ArrayInterface.contiguous_batch_size(typeof(M2.data)) |
| 21 | + @test ArrayInterface.stride_rank(typeof(M2)) === ArrayInterface.stride_rank(typeof(M2.data)) |
| 22 | + @test ArrayInterface.contiguous_axis(typeof(M')) === ArrayInterface.contiguous_axis(typeof(M.data')) |
| 23 | + @test ArrayInterface.contiguous_batch_size(typeof(M')) === ArrayInterface.contiguous_batch_size(typeof(M.data')) |
| 24 | + @test ArrayInterface.stride_rank(typeof(M')) === ArrayInterface.stride_rank(typeof(M.data')) |
11 | 25 | end |
0 commit comments