]> code.communitydata.science - ml_measurement_error_public.git/blob - simulations/grid_sweep.py
git-annex in ntq8312@kibo:/data/ntq8312/ml_measurement_error_public
[ml_measurement_error_public.git] / simulations / grid_sweep.py
1 #!/usr/bin/env python3
2
3 import fire
4 from itertools import product
5 import pyRemembeR
6
7 def main(command, arg_dict, outfile, remember_file='remember_grid_sweep.RDS'):
8     remember = pyRemembeR.remember.Remember()
9     remember.set_file(remember_file)
10     remember[outfile] = arg_dict
11     remember.save_to_r()
12     keys = []
13     values = []
14         
15     for i,p in enumerate(arg_dict.items()):
16         k,v = p
17         keys.append(k)
18         values.append(v)
19         command = command + f" --{k} {{{i}}} "
20
21     args_list = product(*values)
22
23     with open(outfile,'w') as of:
24         for args in args_list:
25             of.write(command.format(*args) + '\n')
26
27 if __name__ == '__main__':
28     fire.Fire(main)

Community Data Science Collective || Want to submit a patch?