Skip to content

Commit 3074536

Browse files
committed
fix killing simulation in non-local folder, fix testing finished plots, add documentation in Readme, stop leaving open a lot of file handles, add testing for 3.6
1 parent aa53bb4 commit 3074536

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

README.rst

+13-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ but StoSim takes over a lot of tedious work from there on. StoSim can
1111
* analyse the results with graphical plots and T-tests (it is easy to analyse results made with specific parameter settings)
1212
* back up code and results (to be able to go back to important milestones)
1313

14-
You can find extensive documentation at http://www.nicolashoening.de/stosim/ and example simulations in the "example" folder.
14+
You can find tutorials and extensive documentation at http://stosim.nicolashoening.de and example simulations in the "example" folder.
1515

1616

1717
Installation/Dependencies
@@ -40,9 +40,18 @@ Running a simulation: A quick overview
4040
Place an experiment configuration (stosim.conf) and your simulation code in a folder of your choice (see basic example in the examples folder).
4141
Call::
4242

43-
stosim --folder <path-to-your-experiment-folder>
43+
stosim
44+
45+
This assumes that you placed a configuration file describing your jobs (called `stosim.conf`) in the current folder.
46+
It also assumes you want to run the jobs, and in addition perform T-Tests and make plots (if stosim.conf says how). So the above command is synonymous to::
47+
48+
stosim --folder . --run --ttests --plots
4449

45-
You can leave the --folder option away if stosim.conf is in the current directory.
4650
The results will be put in the "data" directory, in your folder
47-
(but if you like the plotting capabilities of StoSim you might never have to look there).
51+
(but if you like the plotting/analysis capabilities of StoSim you might never have to look there).
52+
53+
One more example, where you know your stosim.conf is in a different folder and you only want to run::
54+
55+
stosim --folder <path-to-your-experiment-folder> --run
4856

57+
There are more features, e.g. `--more` to add more stochastic runs, `--list` to inspect data or `--snapshot` to make a snapshots of results at a given time that can be loaded back later. Do check out the tutorials where you can learn more.

stosim/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.20'
1+
__version__ = '0.2.22'

stosim/analysis/harvester.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ def collect_values(filepath, delim, outfile_name, cols=[], selector='all'):
6565
vals = []
6666
files = [f for f in os.listdir(filepath) if f.endswith('.dat')]
6767
for f in files:
68-
tmp = open('%s/%s' % (filepath, f), 'r')
69-
vals.extend(selector(tmp, cols, delim))
70-
out = open(outfile_name, 'w')
71-
for v in vals:
72-
out.write('%s' % str(v))
73-
out.close()
74-
68+
with open('%s/%s' % (filepath, f), 'r') as tmp:
69+
vals.extend(selector(tmp, cols, delim))
70+
with open(outfile_name, 'w') as out:
71+
for v in vals:
72+
out.write('%s' % str(v))
7573

7674

7775
# ---- selectors ----

stosim/sim/commands.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def run(simfolder):
5858
copy("{}/jobs/{}".format(simfolder, job),
5959
"{}/jobqueue".format(fjd_dir))
6060
dispatch_cmd = 'fjd-dispatcher --project {} --end_when_jobs_are_done '\
61-
' --callback "stosim --kill" --interval {}'\
62-
.format(sim_name, utils.get_interval(simfolder))
61+
' --callback "stosim --folder {} --kill" --interval {}'\
62+
.format(sim_name, simfolder, utils.get_interval(simfolder))
6363

6464
# now decide if recruiting is done in a local network or on a PBS cluster
6565
scheduler = utils.get_scheduler(simfolder)

stosim/tests/test_integration.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def test_data(self):
5757

5858
def test_plots(self):
5959
assert(os.path.exists('{}/plots'.format(self.edir)))
60-
assert(os.listdir('{}/plots'.format(self.edir)) == self.plots)
60+
plots_made = os.listdir('{}/plots'.format(self.edir))
61+
plots_expected = self.plots
62+
plots_made.sort()
63+
plots_expected.sort()
64+
assert(plots_made == plots_expected)
6165

6266

6367
class TestSubsimExample(TestBasicExample):

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist=py27,py33
2+
envlist=py27,py36
33

44
[testenv]
55
deps=

0 commit comments

Comments
 (0)