nastasiasnk commited on
Commit
7c424e1
1 Parent(s): 4c1bd82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -96,7 +96,33 @@ def test(input_json):
96
 
97
  df_landuses = pd.DataFrame(landuses).T
98
  df_landuses = df_landuses.round(0).astype(int)
 
 
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  # create a mask based on the matrix size and ids, crop activity nodes to the mask
102
  mask_connected = df_matrix.index.tolist()
@@ -271,7 +297,8 @@ def test(input_json):
271
  "livability_dictionary": livability_dictionary,
272
  "subdomainsWeights_dictionary": LivabilitySubdomainsInputs_dictionary,
273
  "luDomainMapper": landuseMapperDict,
274
- "attributeMapper": attributeMapperDict
 
275
  }
276
 
277
 
 
96
 
97
  df_landuses = pd.DataFrame(landuses).T
98
  df_landuses = df_landuses.round(0).astype(int)
99
+
100
+
101
 
102
+ # List containing the substrings to check against
103
+ tranportModes = ["DRT", "GMT", "HSR"]
104
+
105
+ def split_dict_by_subkey(original_dict, substrings):
106
+ # Initialize dictionaries for each substring
107
+ result_dicts = {substring: {} for substring in substrings}
108
+
109
+ for key, nested_dict in original_dict.items():
110
+ for subkey, value in nested_dict.items():
111
+ # Check each substring if it's in the subkey
112
+ for substring in substrings:
113
+ if substring in subkey:
114
+ if key not in result_dicts[substring]:
115
+ result_dicts[substring][key] = {}
116
+ result_dicts[substring][key][subkey] = value
117
+
118
+ return result_dicts
119
+
120
+ result_dicts = split_dict_by_subkey(transport_matrix, tranportModes)
121
+
122
+ # Accessing each dictionary
123
+ art_dict = result_dicts["DRT"]
124
+ gmt_dict = result_dicts["GMT"]
125
+
126
 
127
  # create a mask based on the matrix size and ids, crop activity nodes to the mask
128
  mask_connected = df_matrix.index.tolist()
 
297
  "livability_dictionary": livability_dictionary,
298
  "subdomainsWeights_dictionary": LivabilitySubdomainsInputs_dictionary,
299
  "luDomainMapper": landuseMapperDict,
300
+ "attributeMapper": attributeMapperDict,
301
+ "artDict": art_dict
302
  }
303
 
304