Skip to content

Commit

Permalink
Fix tests & update API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
BenChung committed Dec 9, 2024
1 parent 69872bf commit 1c78dee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/systems/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ function generate_vector_rootfinding_callback(
let save_idxs = save_idxs
custom_init = fn.initialize
(i) -> begin
isnothing(custom_init) && custom_init(i)
!isnothing(custom_init) && custom_init(i)
for idx in save_idxs
SciMLBase.save_discretes!(i, idx)
end
Expand Down
4 changes: 2 additions & 2 deletions src/systems/imperative_affect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ function compile_user_affect(affect::ImperativeAffect, cb, sys, dvs, ps; kwargs.
end
obs_fun = build_explicit_observed_function(
sys, Symbolics.scalarize.(obs_exprs);
array_type = Tuple)
mkarray = (es,_) -> MakeTuple(es))
obs_sym_tuple = (obs_syms...,)

# okay so now to generate the stuff to assign it back into the system
mod_pairs = mod_exprs .=> mod_syms
mod_names = (mod_syms...,)
mod_og_val_fun = build_explicit_observed_function(
sys, Symbolics.scalarize.(first.(mod_pairs));
array_type = Tuple)
mkarray = (es,_) -> MakeTuple(es))

upd_funs = NamedTuple{mod_names}((setu.((sys,), first.(mod_pairs))...,))

Expand Down
8 changes: 4 additions & 4 deletions test/symbolic_events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ end
@named trigsys = ODESystem(eqs, t; continuous_events = [evt1, evt2])
trigsys_ss = structural_simplify(trigsys)
prob = ODEProblem(trigsys_ss, [], (0.0, 2π))
sol = solve(prob, Tsit5())
sol = solve(prob, Tsit5(); dtmax=0.01)
required_crossings_c1 =/ 2, 3 * π / 2]
required_crossings_c2 =/ 6, π / 2, 5 * π / 6, 7 * π / 6, 3 * π / 2, 11 * π / 6]
@test maximum(abs.(first.(cr1) .- required_crossings_c1)) < 1e-4
Expand Down Expand Up @@ -1079,8 +1079,8 @@ end
@test sort(canonicalize(Discrete(), prob.p)[1]) == [0.0, 1.0, 2.0]
sol = solve(prob, Tsit5())

@test sol[a] == [-1.0]
@test sol[b] == [5.0, 5.0]
@test sol[a] == [1.0,-1.0]
@test sol[b] == [2.0,5.0, 5.0]
@test sol[c] == [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
end
@testset "Heater" begin
Expand Down Expand Up @@ -1248,7 +1248,7 @@ end
ss = structural_simplify(sys)
prob = ODEProblem(ss, [theta => 0.0], (0.0, pi))
sol = solve(prob, Tsit5(); dtmax = 0.01)
@test getp(sol, cnt)(sol) == 197 # we get 2 pulses per phase cycle (cos 0 crossing) and we go to 100 cycles; we miss a few due to the initial state
@test getp(sol, cnt)(sol) == 198 # we get 2 pulses per phase cycle (cos 0 crossing) and we go to 100 cycles; we miss a few due to the initial state
end

@testset "Initialization" begin
Expand Down

0 comments on commit 1c78dee

Please sign in to comment.