Skip to content

Commit

Permalink
setting random seed for test simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Jun 15, 2018
1 parent 8e48e5b commit f0f020d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ tests/fixtures/secret/
.Spotlight-V100
.Trashes
.~lock.*
Thumbs.db
Thumbs.db

# configuration
wc_utils.cfg
7 changes: 6 additions & 1 deletion tests/analysis/sim/test_analysis_sim_rna.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def test(self):
# run simulations
sim_results_path = os.path.join(self.temp_dir, 'sim_results')
for i_sim in range(3):
# todo: seed simulation
# todo: use simulation configuration to seed simulation
with open('wc_utils.cfg', 'w') as file:
file.write('[wc_utils]\n')
file.write(' [[random]]\n')
file.write(' seed = {}\n'.format(i_sim))

sim = wc_sim.multialgorithm.simulation.Simulation(model)
sim.run(end_time=10.,
checkpoint_period=1.,
Expand Down
9 changes: 7 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ def test_analyze(self):

# simulate model
for i_sim in range(3):
# todo: seed simulation
# todo: use simulation configuration to seed simulation
with open('wc_utils.cfg', 'w') as file:
file.write('[wc_utils]\n')
file.write(' [[random]]\n')
file.write(' seed = {}\n'.format(i_sim))

with __main__.App(argv=['simulate', '--config-path', self.config_path]) as app:
app.run()
app.run()
time.sleep(1.) # todo: remove after results directory naming is fixed

# analyze simulation results
Expand Down

0 comments on commit f0f020d

Please sign in to comment.