Skip to content

Commit 220c516

Browse files
committed
removed bug
1 parent 0a2e3fb commit 220c516

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

run_main.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"popSize": 96,
1313
"duration": 24,
1414
"nervousSystemFileName" : 'main_sim',
15+
"doNML": 0
1516
}
1617

1718
DEFAULTS = {
@@ -21,7 +22,7 @@
2122
"outputFolderName": None,
2223
"doEvol": False,
2324
"overwrite": False,
24-
"doNML": False,
25+
"doNML": None,
2526
"crandSeed": None,
2627
"inputFolderName": None,
2728
"nervousSystemFileName" : 'main_sim',
@@ -233,7 +234,7 @@ def run(a=None, **kwargs):
233234
sys.exit(1)
234235

235236
if a.outputFolderName is None:
236-
print("You need to supply an output folder name!")
237+
print("No output folder name. You need to supply an output folder name, and an optional input folder name.")
237238
sys.exit(1)
238239

239240
if not do_evol and not os.path.isdir(a.outputFolderName):
@@ -247,10 +248,10 @@ def run(a=None, **kwargs):
247248

248249
if not make_directory(a.outputFolderName, a.overwrite, str1):
249250
print(f"Please change output directory name, or set overwrite to True\n"
250-
"and doEvol to True to overwrite the evolution results,\n"
251+
"and doEvol to True to overwrite the evolution and simulation results,\n"
251252
"or set overwrite to True and doEvol to False (the default) if you want\n"
252-
"to just overwrite the simulation results. Alternatively supply this directory"
253-
"as the `inputFolderName' parameter (which will not be"
253+
"to just overwrite the simulation results. Alternatively supply this directory\n"
254+
"as the `inputFolderName' parameter (which will not be\n"
254255
"modified), and provide a different novel name for the output directory."
255256
)
256257
sys.exit(1)
@@ -279,7 +280,7 @@ def run(a=None, **kwargs):
279280
evol_data = {}
280281
evol_pars = ['Duration', 'pop_size', 'randomseed']
281282
evol_args = [a.duration, a.popSize, a.RandSeed]
282-
evol_defaults = [24, 96, random_seed]
283+
evol_defaults = [defaults_base['duration'], defaults_base['popSize'], random_seed]
283284

284285
evol_par_file = a.outputFolderName + '/worm_data.json'
285286
if os.path.isfile(evol_par_file):
@@ -291,13 +292,7 @@ def run(a=None, **kwargs):
291292
else:
292293
print('Parameter not found in worm_data.json')
293294

294-
295-
if a.doNML:
296-
do_nml = 1
297-
else:
298-
do_nml = 0
299-
300-
295+
301296
same_vals = True
302297
if do_evol:
303298
for (par, arg, default) in zip(evol_pars,evol_args,evol_defaults):
@@ -306,17 +301,24 @@ def run(a=None, **kwargs):
306301
print('Evolution not needed as evolution parameters are the same as the existing ones.')
307302
do_evol = False
308303

304+
if a.doNML is not None:
305+
if a.doNML:
306+
do_nml = 1
307+
else:
308+
do_nml = 0
309309

310310
same_vals = True
311311
sim_pars = ['doNML', 'seed', 'Duration']
312312
sim_args = [do_nml, a.RandSeed, a.duration]
313-
sim_defaults = [0, random_seed, 24]
313+
sim_defaults = [defaults_base['doNML'], random_seed, defaults_base['duration']]
314314
for (par, arg, default) in zip(sim_pars,sim_args,sim_defaults):
315315
if not setDict(sim_data, par, arg, default): same_vals = False
316316

317317

318318
if not do_evol and same_vals:
319-
print('Simulation not needed as simulation parameters are the same as the existing ones.')
319+
print('Simulation not needed as simulation parameters are the same as the existing ones.\n'
320+
'Please supply new command line arguments.'
321+
)
320322
sys.exit(1)
321323

322324
with open(sim_par_file, 'w', encoding='utf-8') as f:
@@ -336,7 +338,7 @@ def run(a=None, **kwargs):
336338
cmd += ["-sd", str(sim_data['Duration'])]
337339
cmd += ["--doevol", str(do_evol)]
338340

339-
cmd += ["--donml", str(do_nml)]
341+
cmd += ["--donml", str(sim_data['doNML'])]
340342
cmd += ["--folder", str(a.outputFolderName)]
341343

342344

0 commit comments

Comments
 (0)