From db87fee0408775df47095416e0df14caa98d7c9a Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Sun, 22 Dec 2024 12:01:33 +0000 Subject: [PATCH] Black reformating --- premise/pathways.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/premise/pathways.py b/premise/pathways.py index ff546714..db35734c 100644 --- a/premise/pathways.py +++ b/premise/pathways.py @@ -234,10 +234,16 @@ def add_variables_mapping(self): if "configurations" in scenario: configurations = scenario["configurations"] for key, val in configurations.items(): - for variable, variable_details in val.get("production pathways", {}).items(): + for variable, variable_details in val.get( + "production pathways", {} + ).items(): if variable not in mapping: - variable_scenario_name = variable_details.get("production volume", {}).get("variable", 0) - mapping[variable] = {"scenario variable": variable_scenario_name} + variable_scenario_name = variable_details.get( + "production volume", {} + ).get("variable", 0) + mapping[variable] = { + "scenario variable": variable_scenario_name + } filters = variable_details.get("ecoinvent alias") mask = variable_details.get("ecoinvent alias").get("mask") @@ -256,14 +262,14 @@ def add_variables_mapping(self): ] if len(mapping[variable]["dataset"]) == 0: - print(f"No dataset found for {variable} in {variable_scenario_name}") + print( + f"No dataset found for {variable} in {variable_scenario_name}" + ) print(f"Filters: {filters}") print(f"Mask: {mask}") continue - variables = list( - val["production pathways"].keys() - ) + variables = list(val["production pathways"].keys()) variables.remove(variable) # remove datasets which names are in list of variables # except for the current variable @@ -322,7 +328,7 @@ def add_scenario_data(self): # split the columns "scenarios" into "model" and "pathway" df[["model", "pathway"]] = df["scenario"].str.split(" - ", n=1, expand=True) # remove any spaces in the "pathway" column - #df["pathway"] = df["pathway"].str.replace(" ", "") + # df["pathway"] = df["pathway"].str.replace(" ", "") df = df.drop(columns=["scenario"]) self.scenario_names = df["pathway"].unique().tolist()