|
50 | 50 | @test @inferred(ArrayInterface.to_indices(a, (1, 1, 1))) == (1,1, 1)
|
51 | 51 | @test @inferred ArrayInterface.to_indices(a, ([CartesianIndex(1,1,1), CartesianIndex(1,2,1)],)) == (CartesianIndex{3}[CartesianIndex(1, 1, 1), CartesianIndex(1, 2, 1)],)
|
52 | 52 | @test @inferred ArrayInterface.to_indices(a, ([CartesianIndex(1,1), CartesianIndex(1,2)],1:1)) == (CartesianIndex{2}[CartesianIndex(1, 1), CartesianIndex(1, 2)], 1:1)
|
| 53 | + @test @inferred(first(ArrayInterface.to_indices(a, (fill(true, 2, 2, 1),)))) isa Base.LogicalIndex |
| 54 | + |
| 55 | + @test_throws BoundsError ArrayInterface.to_indices(a, (fill(true, 2, 2, 2),)) |
53 | 56 | @test_throws ErrorException ArrayInterface.to_indices(ones(2,2,2), (1, 1))
|
54 | 57 | end
|
55 | 58 |
|
| 59 | +@testset "to_axes" begin |
| 60 | + A = ones(3, 3) |
| 61 | + axis = StaticInt(1):StaticInt(3) |
| 62 | + inds = StaticInt(1):StaticInt(2) |
| 63 | + multi_inds = [CartesianIndex(1, 1), CartesianIndex(1, 2)] |
| 64 | + |
| 65 | + @test @inferred(ArrayInterface.to_axes(A, (axis, axis), (inds, inds))) === (inds, inds) |
| 66 | + # vector indexing |
| 67 | + @test @inferred(ArrayInterface.to_axes(ones(3), (axis,), (inds,))) === (inds,) |
| 68 | + # linear indexing |
| 69 | + @test @inferred(ArrayInterface.to_axes(A, (axis, axis), (inds,))) === (inds,) |
| 70 | + # multidim arg |
| 71 | + @test @inferred(ArrayInterface.to_axes(A, (axis, axis), (multi_inds,))) === (Base.OneTo(2),) |
| 72 | +end |
| 73 | + |
56 | 74 | @testset "0-dimensional" begin
|
57 | 75 | x = Array{Int,0}(undef)
|
58 | 76 | ArrayInterface.setindex!(x, 1)
|
|
0 commit comments