diff --git a/activity_browser/bwutils/montecarlo.py b/activity_browser/bwutils/montecarlo.py index 67314eeda..c1d8e067c 100644 --- a/activity_browser/bwutils/montecarlo.py +++ b/activity_browser/bwutils/montecarlo.py @@ -50,26 +50,11 @@ def __init__(self, cs_name): self.activity_keys = [list(fu.keys())[0] for fu in self.func_units] self.activity_index = {key: index for index, key in enumerate(self.activity_keys)} self.rev_activity_index = {index: key for index, key in enumerate(self.activity_keys)} - # previously: self.rev_activity_index = {v: k for k, v in self.activity_keys} - # self.fu_index = {k: i for i, k in enumerate(self.activity_keys)} # methods self.methods = self.cs['ia'] self.method_index = {m: i for i, m in enumerate(self.methods)} self.rev_method_index = {i: m for i, m in enumerate(self.methods)} - # previously: self.rev_method_index = {v: k for k, v in self.method_index.items()} - # self.rev_method_index = {v: k for k, v in self.method_index.items()} - - # todo: get rid of the below - self.func_unit_translation_dict = {str(bw.get_activity(list(func_unit.keys())[0])): func_unit - for func_unit in self.func_units} - if len(self.func_unit_translation_dict) != len(self.func_units): - self.func_unit_translation_dict = {} - for fu in self.func_units: - act = bw.get_activity(next(iter(fu))) - self.func_unit_translation_dict["{} {}".format(act, act[0])] = fu - self.func_key_dict = {m: i for i, m in enumerate(self.func_unit_translation_dict.keys())} - self.func_key_list = list(self.func_key_dict.keys()) # GSA calculation variables self.A_matrices = list() diff --git a/activity_browser/bwutils/multilca.py b/activity_browser/bwutils/multilca.py index 7c0e0b0f8..4abd6aeb8 100644 --- a/activity_browser/bwutils/multilca.py +++ b/activity_browser/bwutils/multilca.py @@ -170,17 +170,17 @@ def __init__(self, cs_name: str): self.process_contributions = np.zeros( (len(self.func_units), len(self.methods), self.lca.technosphere_matrix.shape[0])) - # TODO: get rid of the below - self.func_unit_translation_dict = { - str(bw.get_activity(list(func_unit.keys())[0])): func_unit for func_unit in self.func_units - } - if len(self.func_unit_translation_dict) != len(self.func_units): - self.func_unit_translation_dict = {} - for fu in self.func_units: - act = bw.get_activity(next(iter(fu))) - self.func_unit_translation_dict["{} {}".format(act, act[0])] = fu + name = 'name' + ref_prod = 'reference product' + db = 'database' + self.func_unit_translation_dict = {} + for fu in self.func_units: + key = next(iter(fu)) + amt = fu[key] + act = bw.get_activity(key) + self.func_unit_translation_dict[f'{act[name]} | {act[ref_prod]} | {act[db]} | {amt}'] = fu self.func_key_dict = {m: i for i, m in enumerate(self.func_unit_translation_dict.keys())} - self.func_key_list = list(self.func_key_dict.keys()) + self.func_key_list = list(self.func_unit_translation_dict.keys()) def _construct_lca(self): return bw.LCA(demand=self.func_units_dict, method=self.methods[0])