e-courage: modularizing backwards compatability

This commit is contained in:
Joshua E. Jodesty 2019-02-18 14:20:59 -05:00
parent 5863188617
commit e30388ff6b
3 changed files with 9 additions and 5 deletions

View File

@ -4,6 +4,8 @@ from copy import deepcopy
from fn.func import curried
import pandas as pd
# Temporary
from cadCAD.configuration.utils.depreciationHandler import sanitize_partial_state_updates
from cadCAD.utils import dict_filter, contains_type
@ -13,7 +15,10 @@ class TensorFieldReport:
self.config_proc = config_proc
# ToDo: backwards compatibility
def create_tensor_field(self, partial_state_updates, exo_proc, keys=['policies', 'variables']):
def create_tensor_field(self, partial_state_updates, exo_proc, keys = ['policies', 'variables']):
partial_state_updates = sanitize_partial_state_updates(partial_state_updates) # Temporary
dfs = [self.config_proc.create_matrix_field(partial_state_updates, k) for k in keys]
df = pd.concat(dfs, axis=1)
for es, i in zip(exo_proc, range(len(exo_proc))):

View File

@ -21,7 +21,6 @@ def sanitize_partial_state_updates(partial_state_updates):
# for backwards compatibility we accept the old keys
# ('behaviors' and 'states') and rename them
def rename_keys(d):
if 'behaviors' in d:
d['policies'] = d.pop('behaviors')

View File

@ -120,7 +120,7 @@ partial_state_update_block = {
"b1": p1m1,
# "b2": p2m1
},
"variables": {
"states": {
"s1": s1m1,
# "s2": s2m1
}
@ -130,7 +130,7 @@ partial_state_update_block = {
"b1": p1m2,
# "b2": p2m2
},
"variables": {
"states": {
"s1": s1m2,
# "s2": s2m2
}
@ -140,7 +140,7 @@ partial_state_update_block = {
"b1": p1m3,
"b2": p2m3
},
"variables": {
"states": {
"s1": s1m3,
"s2": s2m3
}