packaging pt 2
This commit is contained in:
parent
b2cd2f8856
commit
b767792c00
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,6 +11,8 @@ def main():
|
|||
configs = generate_config(mechanisms, exogenous_states)
|
||||
# p = pipeline(states_list, configs, env_processes, range(10))
|
||||
N = sim_config['N']
|
||||
s = simulation(states_list, configs, env_processes, range(5), N)
|
||||
r = range(5)
|
||||
# Dimentions: N x r x mechs
|
||||
s = simulation(states_list, configs, env_processes, r, N)
|
||||
result = pd.DataFrame(flatten(s))
|
||||
print(tabulate(result, headers='keys', tablefmt='psql'))
|
||||
|
|
|
|||
|
|
@ -42,11 +42,14 @@ def env_proc(trigger_step, update_f):
|
|||
return lambda x: x
|
||||
return partial(env_step_trigger, trigger_step, update_f)
|
||||
|
||||
|
||||
# accept timedelta instead of timedelta params
|
||||
def time_step(dt_str, dt_format='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=30):
|
||||
dt = datetime.strptime(dt_str, dt_format)
|
||||
t = dt + timedelta(days=days, minutes=minutes, seconds=seconds)
|
||||
return t.strftime(dt_format)
|
||||
|
||||
# accept timedelta instead of timedelta params
|
||||
def ep_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):
|
||||
if s['mech_step'] == 0:
|
||||
return time_step(dt_str, fromat_str, days, minutes, seconds)
|
||||
|
|
|
|||
|
|
@ -1301,13 +1301,13 @@
|
|||
{
|
||||
"ename": "NameError",
|
||||
"evalue": "name 'non_numeric' is not defined",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-12-9786f8c4c4ba>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m's1'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'3323'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's2'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2572'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's3'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2.657'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's4'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'7.914'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'timestamp'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'2018-10-01 15:16:26'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'mech_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'time_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquantize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTWOPLACES\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mROUND_DOWN\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnon_numeric\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mNameError\u001b[0m: name 'non_numeric' is not defined"
|
||||
]
|
||||
],
|
||||
"output_type": "error"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
|
|
|
|||
15
ui/config.py
15
ui/config.py
|
|
@ -33,7 +33,6 @@ def s1m1(step, sL, s, _input):
|
|||
def s2m1(step, sL, s, _input):
|
||||
s['s2'] = s['s2'] + _input
|
||||
|
||||
|
||||
def s1m2(step, sL, s, _input):
|
||||
s['s1'] = s['s1'] + _input
|
||||
def s2m2(step, sL, s, _input):
|
||||
|
|
@ -51,16 +50,16 @@ def es3p1(step, sL, s, _input):
|
|||
s['s3'] = s['s3'] * bound_norm_random(seed['a'], proc_one_coef_A, proc_one_coef_B)
|
||||
def es4p2(step, sL, s, _input):
|
||||
s['s4'] = s['s4'] * bound_norm_random(seed['b'], proc_one_coef_A, proc_one_coef_B)
|
||||
def es5p2(step, sL, s, _input):
|
||||
def es5p2(step, sL, s, _input): # accept timedelta instead of timedelta params
|
||||
s['timestamp'] = ep_time_step(s, s['timestamp'], seconds=1)
|
||||
|
||||
# Environment States
|
||||
def env_a(x):
|
||||
return x
|
||||
return 10
|
||||
def env_b(x):
|
||||
return x
|
||||
def what_ever(x):
|
||||
return x + 1
|
||||
return 10
|
||||
# def what_ever(x):
|
||||
# return x + 1
|
||||
|
||||
# Genesis States
|
||||
state_dict = {
|
||||
|
|
@ -82,10 +81,12 @@ env_processes = {
|
|||
"s4": env_proc('2018-10-01 15:16:25', env_b)
|
||||
}
|
||||
|
||||
# test return vs. non-return functions as lambdas
|
||||
# test fully defined functions
|
||||
mechanisms = {
|
||||
"m1": {
|
||||
"behaviors": {
|
||||
"b1": b1m1,
|
||||
"b1": b1m1, # lambda step, sL, s: s['s1'] + 1,
|
||||
"b2": b2m1
|
||||
},
|
||||
"states": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue