-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debug M dictionairy unpacking in utils. (#343)
* Debug M dictionairy unpacking in utils. * Update deepcopy_off in easy_run.
- Loading branch information
1 parent
c2ae474
commit 3317b82
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from cadCAD.tools.execution import easy_run | ||
|
||
# def test_empty_easy_run(): | ||
# state_variables = { | ||
# } | ||
# | ||
# params = { | ||
# } | ||
# | ||
# psubs = [ | ||
# { | ||
# 'policies': {}, | ||
# 'variables': {}, | ||
# }, | ||
# ] | ||
# | ||
# N_timesteps = 2 | ||
# | ||
# N_samples = 1 | ||
# | ||
# results = easy_run( | ||
# state_variables, | ||
# params, | ||
# psubs, | ||
# N_timesteps, | ||
# N_samples, | ||
# ) | ||
# print(results) | ||
|
||
|
||
|
||
def test_easy_run(): | ||
state_variables = { | ||
'a':0.5, | ||
} | ||
|
||
params = { | ||
'c':[1, 2], | ||
'd':[1, 2], | ||
} | ||
|
||
def p(params, substep, state_history, previous_state): | ||
a_delta = 1 - params['c'] * previous_state['a'] | ||
return {'a_delta': a_delta} | ||
|
||
def s(params, substep, state_history, previous_state, policy_input): | ||
return 'a', previous_state['a'] + policy_input['a_delta'] | ||
|
||
psubs = [ | ||
{ | ||
'policies': {'p': p}, | ||
'variables': {'a': s}, | ||
}, | ||
] | ||
|
||
N_timesteps = 2 | ||
|
||
N_samples = 1 | ||
|
||
results = easy_run( | ||
state_variables, | ||
params, | ||
psubs, | ||
N_timesteps, | ||
N_samples, | ||
) |