@@ -84,9 +84,12 @@ G2 = sf.g(u,p,t)
8484# test with JumpSystem
8585js = convert (JumpSystem, rs)
8686
87- @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.MassActionJump , [1 ]))
88- @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.ConstantRateJump , 2 : 5 ))
89- @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.VariableRateJump , 6 : 7 ))
87+ midxs = 1 : 14
88+ cidxs = 15 : 18
89+ vidxs = 19 : 20
90+ @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.MassActionJump , midxs))
91+ @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.ConstantRateJump , cidxs))
92+ @test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.VariableRateJump , vidxs))
9093
9194pars = rand (length (k)); u0 = rand (1 : 10 ,4 ); time = rand ();
9295jumps = Vector {Union{ConstantRateJump, MassActionJump, VariableRateJump}} (undef,length (rxs))
@@ -116,21 +119,21 @@ jumps[20] = VariableRateJump((u,p,t) -> p[20]*t*u[1]*binomial(u[2],2)*u[3], inte
116119
117120statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
118121parammap = map ((x,y)-> Pair (x (),y),parameters (js),pars)
119- maj = MT . assemble_maj (js . eqs[ 1 ], statetoid, ModelingToolkit . substituter ( first .(parammap), last .(parammap)), eltype (pars))
120- for i = 1 : 14
121- @test abs (jumps[i]. scaled_rates - maj. scaled_rates[i] ) < 100 * eps ()
122- @test jumps[i]. reactant_stoch == maj. reactant_stoch[i]
123- @test jumps[i]. net_stoch == maj. net_stoch[i]
122+ for i in midxs
123+ maj = MT . assemble_maj (js . eqs[i], statetoid, ModelingToolkit . substituter (parammap), eltype (pars))
124+ @test abs (jumps[i]. scaled_rates - maj. scaled_rates) < 100 * eps ()
125+ @test jumps[i]. reactant_stoch == maj. reactant_stoch
126+ @test jumps[i]. net_stoch == maj. net_stoch
124127end
125- for i = 15 : 18
126- crj = MT. assemble_crj (js, js. eqs[i- 13 ], statetoid)
128+ for i in cidxs
129+ crj = MT. assemble_crj (js, js. eqs[i], statetoid)
127130 @test isapprox (crj. rate (u0,p,time), jumps[i]. rate (u0,p,time))
128131 fake_integrator1 = (u= zeros (4 ),p= p,t= 0 ); fake_integrator2 = deepcopy (fake_integrator1);
129132 crj. affect! (fake_integrator1); jumps[i]. affect! (fake_integrator2);
130133 @test fake_integrator1 == fake_integrator2
131134end
132- for i = 19 : 20
133- crj = MT. assemble_vrj (js, js. eqs[i- 13 ], statetoid)
135+ for i in vidxs
136+ crj = MT. assemble_vrj (js, js. eqs[i], statetoid)
134137 @test isapprox (crj. rate (u0,p,time), jumps[i]. rate (u0,p,time))
135138 fake_integrator1 = (u= zeros (4 ),p= p,t= 0. ); fake_integrator2 = deepcopy (fake_integrator1);
136139 crj. affect! (fake_integrator1); jumps[i]. affect! (fake_integrator2);
0 commit comments