diff --git a/premise/activity_maps.py b/premise/activity_maps.py index 3cfa09d2..b62fa740 100644 --- a/premise/activity_maps.py +++ b/premise/activity_maps.py @@ -249,5 +249,8 @@ def generate_sets_from_filters(self, filtr: dict, database=None) -> dict: database = database or self.database - techs = {tech: act_fltr(database, fltr.get("fltr"), fltr.get("mask")) for tech, fltr in filtr.items()} + techs = { + tech: act_fltr(database, fltr.get("fltr"), fltr.get("mask")) + for tech, fltr in filtr.items() + } return {tech: {act["name"] for act in actlst} for tech, actlst in techs.items()} diff --git a/premise/data_collection.py b/premise/data_collection.py index fccf534a..c2c9f1cb 100644 --- a/premise/data_collection.py +++ b/premise/data_collection.py @@ -685,7 +685,9 @@ def __get_iam_data( dataframe = dataframe.drop("index", axis=1) # convert all column names that are string to lower case - dataframe.columns = [x.lower() if isinstance(x, str) else x for x in dataframe.columns] + dataframe.columns = [ + x.lower() if isinstance(x, str) else x for x in dataframe.columns + ] dataframe = dataframe.loc[dataframe["variable"].isin(variables)] @@ -730,9 +732,7 @@ def __fetch_market_data( available_vars = list(set(input_vars.values()) - missing_vars) if available_vars: - market_data = data.loc[ - :, available_vars, : - ] + market_data = data.loc[:, available_vars, :] else: return None @@ -749,7 +749,9 @@ def __fetch_market_data( else: if normalize is True: market_data /= ( - data.loc[:, available_vars, :].groupby("region").sum(dim="variables") + data.loc[:, available_vars, :] + .groupby("region") + .sum(dim="variables") ) # back-fill nans diff --git a/premise/ecoinvent_modification.py b/premise/ecoinvent_modification.py index 3eff017b..1c7659ec 100644 --- a/premise/ecoinvent_modification.py +++ b/premise/ecoinvent_modification.py @@ -772,24 +772,24 @@ def update_electricity(self) -> None: # datasets in 3.9 have been updated if self.version not in ["3.9", "3.9.1"]: - electricity.update_ng_production_ds() + electricity.update_ng_production_ds() electricity.update_efficiency_of_solar_pv() if scenario["iam data"].biomass_markets is not None: - electricity.create_biomass_markets() + electricity.create_biomass_markets() electricity.create_region_specific_power_plants() if scenario["iam data"].electricity_markets is not None: - electricity.update_electricity_markets() + electricity.update_electricity_markets() else: - print("No electricity markets found in IAM data. Skipping.") + print("No electricity markets found in IAM data. Skipping.") if scenario["iam data"].electricity_efficiencies is not None: - electricity.update_electricity_efficiency() + electricity.update_electricity_efficiency() else: - print("No electricity efficiencies found in IAM data. Skipping.") + print("No electricity efficiencies found in IAM data. Skipping.") scenario["database"] = electricity.database self.modified_datasets = electricity.modified_datasets diff --git a/premise/electricity.py b/premise/electricity.py index 8db65cd2..aff1239e 100644 --- a/premise/electricity.py +++ b/premise/electricity.py @@ -874,7 +874,7 @@ def create_new_markets_high_voltage(self) -> None: ["RER"], ["RoW"], ["CH"], - list(self.ecoinvent_to_iam_loc.keys()) + list(self.ecoinvent_to_iam_loc.keys()), ] tech_suppliers = defaultdict(list) @@ -920,7 +920,9 @@ def create_new_markets_high_voltage(self) -> None: if self.system_model == "consequential": continue else: - raise IndexError(f"Couldn't find suppliers for {technology} when looking for {ecoinvent_technologies[technology]}.") + raise IndexError( + f"Couldn't find suppliers for {technology} when looking for {ecoinvent_technologies[technology]}." + ) if self.system_model == "consequential": periods = [ @@ -1964,8 +1966,10 @@ def create_missing_power_plant_datasets(self) -> None: if "input" in e: del e["input"] - ds["comment"] = "This dataset is a proxy dataset for a power plant. " \ - "It is used to create missing power plant datasets." + ds["comment"] = ( + "This dataset is a proxy dataset for a power plant. " + "It is used to create missing power plant datasets." + ) self.database.extend(new_datasets.values()) diff --git a/premise/geomap.py b/premise/geomap.py index 2920dec0..bcaf89ab 100644 --- a/premise/geomap.py +++ b/premise/geomap.py @@ -77,8 +77,8 @@ def __init__(self, model: str) -> None: self.rev_additional_mappings = {} for key, val in self.additional_mappings.items(): if ( - self.model.upper(), - val[self.model], + self.model.upper(), + val[self.model], ) not in self.rev_additional_mappings: self.rev_additional_mappings[(self.model.upper(), val[self.model])] = [ key diff --git a/premise/inventory_imports.py b/premise/inventory_imports.py index 8191a009..3c77f5f2 100644 --- a/premise/inventory_imports.py +++ b/premise/inventory_imports.py @@ -569,7 +569,6 @@ def add_biosphere_links(self, delete_missing: bool = False) -> None: self.biosphere_dict[key], ) - def lower_case_technosphere_exchanges(self) -> None: blakclist = [ "NOx", diff --git a/premise/transformation.py b/premise/transformation.py index e568555b..af91761f 100644 --- a/premise/transformation.py +++ b/premise/transformation.py @@ -597,7 +597,9 @@ def fetch_proxies( if production_variable is not None: # Add `production volume` field if isinstance(production_variable, str): - production_variable = [production_variable, ] + production_variable = [ + production_variable, + ] if all( i in self.iam_data.production_volumes.variables