Skip to content

Commit a1bed6c

Browse files
committed
added timeStep info to JSON output for CRA
1 parent 6480342 commit a1bed6c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

delphi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def create_CRA_CAG(args):
1616

1717
with open(args.indra_statements, 'rb') as f:
1818
export_to_CRA(create_dressed_CAG(ltake(args.n_statements,
19-
filter(isSimulable, pickle.load(f)))))
19+
filter(isSimulable, pickle.load(f)))), args.dt)
2020

2121

2222
def create_model(args):

delphi/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_latent_state_components(CAG: DiGraph) -> List[str]:
136136
return flatMap(lambda a: (a, f'∂({a})/∂t'), CAG.nodes())
137137

138138

139-
def initialize_transition_matrix(cs: List[str], Δt = 1) -> DataFrame:
139+
def initialize_transition_matrix(cs: List[str], Δt: float = 1) -> DataFrame:
140140
A = DataFrame(np.identity(len(cs)), cs, cs)
141141
for c in cs[::2]: A[f'∂({c})/∂t'][f'{c}'] = Δt
142142
return A
@@ -236,12 +236,13 @@ def construct_CPT(e, res = 100):
236236
return {'beta': X.tolist(), 'P(beta)': Y.tolist()}
237237

238238

239-
def export_to_CRA(CAG:DiGraph):
239+
def export_to_CRA(CAG:DiGraph, Δt):
240240
with open('cra_cag.json', 'w') as f:
241241
json.dump({
242242
'name' : 'Dynamic Bayes Net Model',
243243
'dateCreated' : str(datetime.datetime.now()),
244244
'variables' : lmap(partial(export_node, CAG), CAG.nodes(data=True)),
245+
'timeStep' : Δt,
245246
'CPTs' : lmap(lambda e: {'source': e[0], 'target': e[1], 'CPT':
246247
construct_CPT(e)}, CAG.edges(data=True))
247248
}, f, indent = 2)

0 commit comments

Comments
 (0)