Skip to content

Commit 4d1c677

Browse files
committed
init
1 parent 40953ac commit 4d1c677

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

test/simulation_and_solving/simulate_ODEs.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,34 @@ end
164164

165165
### Other Tests ###
166166

167+
# Checks that simulations values consistently have Float64 type.
168+
let
169+
# Create model and check simulation value type (FLoat64 values).
170+
# Generally, the tend type should not matter.
171+
rn = @reaction_network begin
172+
(k1,k2), X1 <--> X2
173+
end
174+
u0 = [:X1 => 1.0, :X2 => 3.0]
175+
ps = [:k1 => 2.0, :k2 => 3.0]
176+
oprob = ODEProblem(rn, u0, 1.0, ps)
177+
osol = solve(oprob)
178+
@test eltype(osol[:X1]) == eltype(osol[:X2]) == typeof(oprob[:X1]) == typeof(oprob[:X2]) == Float64
179+
180+
# Check type when input values are Int64.
181+
u0 = [:X1 => 1, :X2 => 3]
182+
ps = [:k1 => 2, :k2 => 3]
183+
oprob = ODEProblem(rn, u0, 1, ps)
184+
osol = solve(oprob)
185+
@test eltype(osol[:X1]) == eltype(osol[:X2]) == typeof(oprob[:X1]) == typeof(oprob[:X2]) == Float64
186+
187+
# Check type when input values are Float32.
188+
u0 = [:X1 => 1.0f0, :X2 => 3.0f0]
189+
ps = [:k1 => 2.0f0, :k2 => 3.0f0]
190+
oprob = ODEProblem(rn, u0, 1.0f0, ps)
191+
osol = solve(oprob)
192+
@test eltype(osol[:X1]) == eltype(osol[:X2]) == typeof(oprob[:X1]) == typeof(oprob[:X2]) == Float32
193+
end
194+
167195
# Tests simulating a network without parameters.
168196
let
169197
no_param_network = @reaction_network begin

test/simulation_and_solving/simulate_SDEs.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,34 @@ end
383383

384384
### Other Tests ###
385385

386+
# Checks that simulations values consistently have Float64 type.
387+
let
388+
# Create model and check simulation value type (FLoat64 values).
389+
# Generally, the tend type should not matter.
390+
rn = @reaction_network begin
391+
(k1,k2), X1 <--> X2
392+
end
393+
u0 = [:X1 => 100.0, :X2 => 300.0]
394+
ps = [:k1 => 2.0, :k2 => 3.0]
395+
sprob = SDEProblem(rn, u0, 1.0, ps)
396+
ssol = solve(sprob, ISSEM())
397+
@test eltype(ssol[:X1]) == eltype(ssol[:X2]) == typeof(sprob[:X1]) == typeof(sprob[:X2]) == Float64
398+
399+
# Check type when input values are Int64.
400+
u0 = [:X1 => 100, :X2 => 300]
401+
ps = [:k1 => 2, :k2 => 3]
402+
sprob = SDEProblem(rn, u0, 1, ps)
403+
ssol = solve(sprob, ISSEM())
404+
@test eltype(ssol[:X1]) == eltype(ssol[:X2]) == typeof(sprob[:X1]) == typeof(sprob[:X2]) == Float64
405+
406+
# Check type when input values are Float32.
407+
u0 = [:X1 => 100.0f0, :X2 => 300.0f0]
408+
ps = [:k1 => 2.0f0, :k2 => 3.0f0]
409+
sprob = SDEProblem(rn, u0, 1.0f0, ps)
410+
ssol = solve(sprob, ISSEM())
411+
@test eltype(ssol[:X1]) == eltype(ssol[:X2]) == typeof(sprob[:X1]) == typeof(sprob[:X2]) == Float32
412+
end
413+
386414
# Tests simulating a network without parameters.
387415
let
388416
no_param_network = @reaction_network begin

test/simulation_and_solving/simulate_jumps.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,40 @@ let
220220
@test (means1[1] - means1[2]) < .1 * means1[1]
221221
@test (means2[1] - means2[2]) < .1 * means2[1]
222222
end
223+
224+
### Other Tests ###
225+
226+
# Checks that simulations values have the correct type (Float64/Int64 depending on input).
227+
let
228+
# Create model and check simulation value type (FLoat64 values).
229+
# Generally, the tend type should not matter.
230+
rn = @reaction_network begin
231+
(k1,k2), X1 <--> X2
232+
end
233+
u0 = [:X1 => 1.0, :X2 => 3.0]
234+
ps = [:k1 => 2.0, :k2 => 3.0]
235+
jprob = JumpProblem(JumpInputs(rn, u0, (0.0, 1.0), ps))
236+
jsol = solve(jprob)
237+
@test eltype(jsol[:X1]) == eltype(jsol[:X2]) == typeof(jprob[:X1]) == typeof(jprob[:X2]) == Float64
238+
239+
# Check type when input values are Int64.
240+
u0 = [:X1 => 1 :X2 => 3]
241+
ps = [:k1 => 2, :k2 => 3]
242+
jprob = JumpProblem(JumpInputs(rn, u0, (0, 1), ps))
243+
jsol = solve(jprob)
244+
@test eltype(jsol[:X1]) == eltype(jsol[:X2]) == typeof(jprob[:X1]) == typeof(jprob[:X2]) == Int64
245+
246+
# Check type when input values are Float32 (should yield types that are ).
247+
u0 = [:X1 => 1.0f0, :X2 => 3.0f0]
248+
ps = [:k1 => 2.0f0, :k2 => 3.0f0]
249+
jprob = JumpProblem(JumpInputs(rn, u0, (0.0f0, 1.0f0), ps))
250+
jsol = solve(jprob)
251+
@test eltype(jsol[:X1]) == eltype(jsol[:X2]) == typeof(jprob[:X1]) == typeof(jprob[:X2]) == Float32
252+
253+
# Check type when input values are Int32 (should yield types that are ).
254+
u0 = [:X1 => Int32(1), :X2 => Int32(3)]
255+
ps = [:k1 => Int32(2), :k2 => Int32(3)]
256+
jprob = JumpProblem(JumpInputs(rn, u0, (Int32(0), Int32(1)), ps))
257+
jsol = solve(jprob)
258+
@test eltype(jsol[:X1]) == eltype(jsol[:X2]) == typeof(jprob[:X1]) == typeof(jprob[:X2]) == Int32
259+
end

0 commit comments

Comments
 (0)