-
Notifications
You must be signed in to change notification settings - Fork 0
/
synthesizer.py
34 lines (27 loc) · 936 Bytes
/
synthesizer.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
28
29
30
31
32
33
34
import json
from subject import *
class Synthesizer:
def __init__(self):
pass
def create_subjects(self, n):
subjects = []
for i in range(1, n+1):
p = Subject(i)
p.set_suspicion_requirements()
p.set_tumor_requirements()
p.set_nodes_requirements()
p.set_metastasis_requirements()
subjects.append(p)
return subjects
def subjects_to_json(self, subjects, file_name):
data = []
for subject in subjects:
subject_dict = vars(subject)
clean_dict = {k: v for k, v in subject_dict.items() if v is not None}
data.append(clean_dict)
with open(file_name, 'w') as f:
json.dump(data, f)
def load_subjects_from_json(self, file_name):
with open(file_name, 'r') as f:
data = json.load(f)
return [Subject(**d) for d in data]