From 6a51a1d94ed636bb5167ced7e75fb6945ad2d18f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:59:06 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/conf.py | 2 +- scripts/build_energy_totals.py | 5 ++--- ...build_industrial_production_per_country.py | 20 +++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a166dd70..efce867e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -342,5 +342,5 @@ texinfo_documents = [ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'https://docs.python.org/': ('https://docs.python.org/3', None), + "https://docs.python.org/": ("https://docs.python.org/3", None), } diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index e508bd54..d8c2f521 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -170,7 +170,7 @@ def eurostat_per_country(input_eurostat: str, country: str) -> pd.DataFrame: sheet_name=None, skiprows=4, index_col=list(range(4)), - na_values=":" + na_values=":", ) sheet.pop("Cover") return pd.concat(sheet) @@ -499,9 +499,8 @@ def idees_per_country(ct: str, base_dir: str) -> pd.DataFrame: assert df.index[9] == "Domestic" assert df.index[10] == "International - Intra-EEAwUK" - ct_totals["total domestic aviation freight"] = df.iloc[[9,10]].sum() + ct_totals["total domestic aviation freight"] = df.iloc[[9, 10]].sum() - assert df.index[11] == "International - Extra-EEAwUK" ct_totals["total international aviation freight"] = df.iloc[11] diff --git a/scripts/build_industrial_production_per_country.py b/scripts/build_industrial_production_per_country.py index 5b691be6..ccb4feca 100644 --- a/scripts/build_industrial_production_per_country.py +++ b/scripts/build_industrial_production_per_country.py @@ -172,14 +172,15 @@ ch_mapping = { "Textil / Leder": "Textiles and leather", "Papier / Druck": "Pulp, paper and printing", "Chemie / Pharma": "Chemical industry", - "Zement / Beton": "Non-metallic mineral products", + "Zement / Beton": "Non-metallic mineral products", "Andere NE-Mineralien": "Other non-ferrous metals", "Metall / Eisen": "Iron and steel", "NE-Metall": "Non Ferrous Metals", - "Metall / Geräte" : "Transport equipment", + "Metall / Geräte": "Transport equipment", "Maschinen": "Machinery equipment", - "Andere Industrien": "Other industrial sectors", - } + "Andere Industrien": "Other industrial sectors", +} + def find_physical_output(df): start = np.where(df.index.str.contains("Physical output", na=""))[0][0] @@ -191,11 +192,12 @@ def find_physical_output(df): def get_energy_ratio(country, eurostat_dir, jrc_dir, year): if country == "CH": # data ranges between 2014-2023 - e_country = pd.read_csv(snakemake.input.ch_industrial_production, - index_col=0).dropna() + e_country = pd.read_csv( + snakemake.input.ch_industrial_production, index_col=0 + ).dropna() e_country = e_country.rename(index=ch_mapping).groupby(level=0).sum() e_country = e_country[str(min(2019, year))] - e_country *= tj_to_ktoe + e_country *= tj_to_ktoe else: ct_eurostat = country.replace("GB", "UK") # estimate physical output, energy consumption in the sector and country @@ -298,7 +300,9 @@ def separate_basic_chemicals(demand, year): year_to_use = min(max(year, 2018), 2022) if year_to_use != year: - logger.info(f"Year {year} outside data range. Using data from {year_to_use} for ammonia production.") + logger.info( + f"Year {year} outside data range. Using data from {year_to_use} for ammonia production." + ) demand.loc[there, "Ammonia"] = ammonia.loc[there, str(year_to_use)] demand["Basic chemicals"] -= demand["Ammonia"]