|
851 | 851 | @test all(Xstack4_dcolon[:a, :, :] .== Xstack4_noca_dcolon[1, :, :])
|
852 | 852 | @test all(Xstack4_dcolon[:b, :, :] .== Xstack4_noca_dcolon[2:3, :, :])
|
853 | 853 | end
|
| 854 | + |
| 855 | + # Test fix https://github.com/Deltares/Ribasim/issues/2028 |
| 856 | + a = range(0.0, 1.0, length=0) |> collect |
| 857 | + b = range(0.0, 1.0; length=2) |> collect |
| 858 | + c = range(0.0, 1.0, length=3) |> collect |
| 859 | + d = range(0.0, 1.0; length=0) |> collect |
| 860 | + u = ComponentVector(a=a, b=b, c=c, d=d) |
| 861 | + |
| 862 | + function get_state_index( |
| 863 | + idx::Int, |
| 864 | + ::ComponentVector{A, B, <:Tuple{<:Axis{NT}}}, |
| 865 | + component_name::Symbol |
| 866 | + ) where {A, B, NT} |
| 867 | + for (comp, range) in pairs(NT) |
| 868 | + if comp == component_name |
| 869 | + return range[idx] |
| 870 | + end |
| 871 | + end |
| 872 | + return nothing |
| 873 | + end |
| 874 | + |
| 875 | + @test_throws BoundsError get_state_index(1, u, :a) |
| 876 | + @test_throws BoundsError get_state_index(2, u, :a) |
| 877 | + @test get_state_index(1, u, :b) == 1 |
| 878 | + @test get_state_index(2, u, :b) == 2 |
| 879 | + @test get_state_index(1, u, :c) == 3 |
| 880 | + @test get_state_index(2, u, :c) == 4 |
| 881 | + @test get_state_index(3, u, :c) == 5 |
| 882 | + @test_throws BoundsError get_state_index(1, u, :d) |
| 883 | + @test_throws BoundsError get_state_index(2, u, :d) |
854 | 884 | end
|
855 | 885 |
|
856 | 886 | @testset "axpy! / axpby!" begin
|
|
0 commit comments