-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathset_params.py
27 lines (26 loc) · 920 Bytes
/
set_params.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import csv
import logging
import ast
def set_params(file):
"""Takes a colon delimited file specifying various parameters,
returns dictionary format of those parameters"""
params = {}
with open(file, 'r') as f:
reader = csv.reader(f, delimiter=":", quotechar='"')
for row in reader:
if row != []:
if row[0].startswith('#'):
pass
else:
params[row[0]] = ast.literal_eval(row[1].strip())
# Check required parameters
if params.get('min_delta', None) is None:
logging.error("Min delta must be provided")
raise ValueError
if params.get('min_abs', None) is None:
logging.error("Min abs must be provided")
raise ValueError
if params.get('num_to_test', None) is None:
logging.error("num to test must be provided")
raise ValueError
return params