Skip to content

Commit 0a09f72

Browse files
test: add tests for new indexing methods
1 parent 016837b commit 0a09f72

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/downstream/symbol_indexing.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ sol_new = DiffEqArray(sol.u[1:10],
2222
@test sol_new[t] sol_new.t
2323
@test sol_new[t, 1:5] sol_new.t[1:5]
2424
@test getp(sol, τ)(sol) == getp(sol_new, τ)(sol_new) == 3.0
25-
@test_deprecated sol[τ]
26-
@test_deprecated sol_new[τ]
25+
@test variable_symbols(sol) == variable_symbols(sol_new) == [x]
26+
@test all_variable_symbols(sol) == all_variable_symbols(sol_new) == [x, RHS]
27+
@test all_symbols(sol) == all_symbols(sol_new) == [x, RHS, τ, t]
28+
@test sol[solvedvariables, 1:10] == sol_new[solvedvariables] == sol_new[[x]]
29+
@test sol[allvariables, 1:10] == sol_new[allvariables] == sol_new[[x, RHS]]
30+
@test_throws Exception sol[τ]
31+
@test_throws Exception sol_new[τ]
2732

2833
# Tables interface
2934
test_tables_interface(sol_new, [:timestamp, Symbol("x(t)")], hcat(sol_new[t], sol_new[x]))

test/symbolic_indexing_interface_test.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ dx = DiffEqArray([[f(x), f2(x)] for x in t],
2121
@test dx[(:a, :b)] == [(f(x), f2(x)) for x in t]
2222
@test dx[[:a, :b], 3] [f(t[3]), f2(t[3])]
2323
@test dx[[:a, :b], 4:5] vcat(f.(t[4:5])', f2.(t[4:5])')
24+
@test dx[solvedvariables] == dx[allvariables] == dx[[:a, :b]]
25+
@test dx[solvedvariables, 3] == dx[allvariables, 3] == dx[[:a, :b], 3]
2426
@test getp(dx, [:p, :q])(dx) == [1.0, 2.0]
2527
@test getp(dx, :p)(dx) == 1.0
2628
@test getp(dx, :q)(dx) == 2.0
27-
@test_deprecated dx[:p]
28-
@test_deprecated dx[[:p, :q]]
29+
@test_throws Exception dx[:p]
30+
@test_throws Exception dx[[:p, :q]]
2931
@test dx[:t] == t
3032

3133
@test symbolic_container(dx) isa SymbolCache
@@ -35,11 +37,12 @@ dx = DiffEqArray([[f(x), f2(x)] for x in t],
3537
@test is_parameter.((dx,), [:a, :b, :p, :q, :t]) == [false, false, true, true, false]
3638
@test parameter_index.((dx,), [:a, :b, :p, :q, :t]) == [nothing, nothing, 1, 2, nothing]
3739
@test is_independent_variable.((dx,), [:a, :b, :p, :q, :t]) == [false, false, false, false, true]
38-
@test variable_symbols(dx) == [:a, :b]
40+
@test variable_symbols(dx) == all_variable_symbols(dx) == [:a, :b]
3941
@test parameter_symbols(dx) == [:p, :q]
4042
@test independent_variable_symbols(dx) == [:t]
4143
@test is_time_dependent(dx)
4244
@test constant_structure(dx)
45+
@test all_symbols(dx) == [:a, :b, :p, :q, :t]
4346

4447
dx = DiffEqArray([[f(x), f2(x)] for x in t], t; variables = [:a, :b])
4548
@test_throws Exception dx[nothing] # make sure it isn't storing [nothing] as indepsym

0 commit comments

Comments
 (0)