From fb263f741b36865c3678a1bd60a0f6e5fa5d9450 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:09:28 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Snakefile | 18 ++++++++++-------- scripts/build_base_energy_totals.py | 20 ++++++++++---------- scripts/build_industrial_database.py | 12 ++++++------ scripts/plot_summary.py | 8 +++++--- scripts/prepare_airports.py | 6 +++--- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/Snakefile b/Snakefile index 53819559..3367f42b 100644 --- a/Snakefile +++ b/Snakefile @@ -96,7 +96,7 @@ rule prepare_sector_networks: RDIR + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc", **config["scenario"], - **config["costs"] + **config["costs"], ), @@ -107,7 +107,7 @@ rule override_res_all_nets: + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_presec.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), @@ -118,7 +118,7 @@ rule solve_all_networks: + "/postnetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), @@ -212,9 +212,11 @@ rule prepare_sector_network: + RDIR_PE + "bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson" ), - pipelines="data_custom/pipelines.csv" - if config["custom_data"]["gas_network"] - else "resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv", + pipelines=( + "data_custom/pipelines.csv" + if config["custom_data"]["gas_network"] + else "resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv" + ), output: RDIR + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc", @@ -596,7 +598,7 @@ rule make_summary: + "/postnetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), costs=CDIR + "costs_{planning_horizons}.csv", plots=expand( @@ -604,7 +606,7 @@ rule make_summary: + "/maps/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}-costs-all_{planning_horizons}_{discountrate}_{demand}_{h2export}export.pdf", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), output: nodal_costs=SDIR + "/csvs/nodal_costs.csv", diff --git a/scripts/build_base_energy_totals.py b/scripts/build_base_energy_totals.py index 9cb6d473..a5eb3f5c 100644 --- a/scripts/build_base_energy_totals.py +++ b/scripts/build_base_energy_totals.py @@ -95,9 +95,9 @@ def calc_sector(sector): energy_totals_base.at[country, "total domestic aviation"] = np.NaN elif sector == "navigation": - energy_totals_base.at[ - country, "total international navigation" - ] = np.NaN + energy_totals_base.at[country, "total international navigation"] = ( + np.NaN + ) energy_totals_base.at[country, "total domestic navigation"] = np.NaN _logger.warning("No data for " + country + " in the sector " + sector + ".") @@ -274,13 +274,13 @@ def calc_sector(sector): ) elif sector == "navigation": - energy_totals_base.at[ - country, "total international navigation" - ] = round( - df_sector[ - df_sector.Transaction == "International marine bunkers" - ].Quantity_TWh.sum(), - 4, + energy_totals_base.at[country, "total international navigation"] = ( + round( + df_sector[ + df_sector.Transaction == "International marine bunkers" + ].Quantity_TWh.sum(), + 4, + ) ) energy_totals_base.at[country, "total domestic navigation"] = round( df_sector[ diff --git a/scripts/build_industrial_database.py b/scripts/build_industrial_database.py index 92a43b1a..731ce023 100644 --- a/scripts/build_industrial_database.py +++ b/scripts/build_industrial_database.py @@ -277,9 +277,9 @@ def create_cement_db(): ) avg_c_cap = df_cement.groupby(df_cement.country)["capacity"].mean() df_cement["capacity"] = df_cement.apply( - lambda x: avg_c_cap[x["country"]] - if math.isnan(x["capacity"]) - else x["capacity"], + lambda x: ( + avg_c_cap[x["country"]] if math.isnan(x["capacity"]) else x["capacity"] + ), axis=1, ) @@ -455,9 +455,9 @@ def create_paper_df(): na_index df_paper["capacity"] = df_paper.apply( - lambda x: avg_c_cap[x["country"]] - if math.isnan(x["capacity"]) - else x["capacity"], + lambda x: ( + avg_c_cap[x["country"]] if math.isnan(x["capacity"]) else x["capacity"] + ), axis=1, ) diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index 228dbbb8..5921d693 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -269,9 +269,11 @@ def plot_balances(): # remove trailing link ports df.index = [ - i[:-1] - if ((i != "co2") and (i != "H2") and (i[-1:] in ["0", "1", "2", "3"])) - else i + ( + i[:-1] + if ((i != "co2") and (i != "H2") and (i[-1:] in ["0", "1", "2", "3"])) + else i + ) for i in df.index ] diff --git a/scripts/prepare_airports.py b/scripts/prepare_airports.py index 7bfd24b5..cc12b462 100644 --- a/scripts/prepare_airports.py +++ b/scripts/prepare_airports.py @@ -94,9 +94,9 @@ def download_airports(): df.insert(2, "airport_size_nr", 1) df.loc[df["type"].isin(["medium_airport"]), "airport_size_nr"] = 1 - df.loc[ - df["type"].isin(["large_airport"]), "airport_size_nr" - ] = snakemake.params.airport_sizing_factor + df.loc[df["type"].isin(["large_airport"]), "airport_size_nr"] = ( + snakemake.params.airport_sizing_factor + ) # Calculate the number of total airports size df1 = df.copy()