Skip to content

Commit

Permalink
Black reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jul 27, 2023
1 parent e6a4fa0 commit b1763b0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
5 changes: 4 additions & 1 deletion premise/activity_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
12 changes: 7 additions & 5 deletions premise/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions premise/electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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())

Expand Down
4 changes: 2 additions & 2 deletions premise/geomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion premise/inventory_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion premise/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1763b0

Please sign in to comment.