rename keys in partial state update blocks
This commit is contained in:
parent
25aa912c2b
commit
b19819bd7d
|
|
@ -73,9 +73,9 @@ class Processor:
|
||||||
self.apply_identity_funcs = id.apply_identity_funcs
|
self.apply_identity_funcs = id.apply_identity_funcs
|
||||||
|
|
||||||
def create_matrix_field(self, mechanisms, key):
|
def create_matrix_field(self, mechanisms, key):
|
||||||
if key == 'states':
|
if key == 'state_update_functions':
|
||||||
identity = self.state_identity
|
identity = self.state_identity
|
||||||
elif key == 'behaviors':
|
elif key == 'policies':
|
||||||
identity = self.behavior_identity
|
identity = self.behavior_identity
|
||||||
df = pd.DataFrame(key_filter(mechanisms, key))
|
df = pd.DataFrame(key_filter(mechanisms, key))
|
||||||
col_list = self.apply_identity_funcs(identity, df, list(df.columns))
|
col_list = self.apply_identity_funcs(identity, df, list(df.columns))
|
||||||
|
|
@ -109,8 +109,19 @@ class Processor:
|
||||||
return sdf_values, bdf_values
|
return sdf_values, bdf_values
|
||||||
|
|
||||||
if len(mechanisms) != 0:
|
if len(mechanisms) != 0:
|
||||||
bdf = self.create_matrix_field(mechanisms, 'behaviors')
|
# for backwards compatibility we accept the old keys
|
||||||
sdf = self.create_matrix_field(mechanisms, 'states')
|
# ('behaviors' and 'states') and rename them
|
||||||
|
for k, v in mechanisms.items():
|
||||||
|
try:
|
||||||
|
v['policies'] = v.pop('behaviors')
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
v['state_update_functions'] = v.pop('states')
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
bdf = self.create_matrix_field(mechanisms, 'policies')
|
||||||
|
sdf = self.create_matrix_field(mechanisms, 'state_update_functions')
|
||||||
sdf_values, bdf_values = no_update_handler(bdf, sdf)
|
sdf_values, bdf_values = no_update_handler(bdf, sdf)
|
||||||
zipped_list = list(zip(sdf_values, bdf_values))
|
zipped_list = list(zip(sdf_values, bdf_values))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class TensorFieldReport:
|
||||||
def __init__(self, config_proc):
|
def __init__(self, config_proc):
|
||||||
self.config_proc = config_proc
|
self.config_proc = config_proc
|
||||||
|
|
||||||
def create_tensor_field(self, mechanisms, exo_proc, keys=['behaviors', 'states']):
|
def create_tensor_field(self, mechanisms, exo_proc, keys=['policies', 'state_update_functions']):
|
||||||
dfs = [self.config_proc.create_matrix_field(mechanisms, k) for k in keys]
|
dfs = [self.config_proc.create_matrix_field(mechanisms, k) for k in keys]
|
||||||
df = pd.concat(dfs, axis=1)
|
df = pd.concat(dfs, axis=1)
|
||||||
for es, i in zip(exo_proc, range(len(exo_proc))):
|
for es, i in zip(exo_proc, range(len(exo_proc))):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue