diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b3a4dfc..b79e959d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: # Sort package imports alphabetically - repo: https://github.com/PyCQA/isort - rev: 5.11.4 + rev: 5.12.0 hooks: - id: isort args: ["--profile", "black", "--filter-files"] @@ -51,7 +51,7 @@ repos: # Formatting with "black" coding style - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: # Format Python files - id: black @@ -74,7 +74,7 @@ repos: # Format Snakemake rule / workflow files - repo: https://github.com/snakemake/snakefmt - rev: v0.8.0 + rev: v0.8.1 hooks: - id: snakefmt diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 85391a64..b9f37db4 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -394,12 +394,10 @@ def attach_conventional_generators( ) for carrier in conventional_config: - # Generators with technology affected idx = n.generators.query("carrier == @carrier").index for attr in list(set(conventional_config[carrier]) & set(n.generators)): - values = conventional_config[carrier][attr] if f"conventional_{carrier}_{attr}" in conventional_inputs: diff --git a/scripts/base_network.py b/scripts/base_network.py index f851a521..565d4907 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -694,7 +694,6 @@ def base_network( parameter_corrections, config, ): - buses = _load_buses_from_eg(eg_buses, europe_shape, config["electricity"]) links = _load_links_from_eg(buses, eg_links) diff --git a/scripts/build_load_data.py b/scripts/build_load_data.py index 780a651e..986892fc 100755 --- a/scripts/build_load_data.py +++ b/scripts/build_load_data.py @@ -268,7 +268,6 @@ def manual_adjustment(load, fn_load, powerstatistics): if __name__ == "__main__": - if "snakemake" not in globals(): from _helpers import mock_snakemake diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 80998b20..6a1d58ec 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -238,7 +238,6 @@ def distribute_clusters(n, n_clusters, focus_weights=None, solver_name="cbc"): ), f"Number of clusters must be {len(N)} <= n_clusters <= {N.sum()} for this selection of countries." if focus_weights is not None: - total_focus = sum(list(focus_weights.values())) assert ( @@ -396,7 +395,6 @@ def clustering_for_n_clusters( extended_link_costs=0, focus_weights=None, ): - bus_strategies, generator_strategies = get_aggregation_strategies( aggregation_strategies ) diff --git a/scripts/make_summary.py b/scripts/make_summary.py index 4c3c675a..815f7aec 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -164,7 +164,6 @@ def calculate_curtailment(n, label, curtailment): def calculate_energy(n, label, energy): for c in n.iterate_components(n.one_port_components | n.branch_components): - if c.name in {"Generator", "Load", "ShuntImpedance"}: c_energies = ( c.pnl.p.multiply(n.snapshot_weightings.generators, axis=0) @@ -238,7 +237,6 @@ def calculate_supply(n, label, supply): load_types = n.buses.carrier.unique() for i in load_types: - buses = n.buses.query("carrier == @i").index bus_map = pd.Series(False, index=n.buses.index) @@ -246,7 +244,6 @@ def calculate_supply(n, label, supply): bus_map.loc[buses] = True for c in n.iterate_components(n.one_port_components): - items = c.df.index[c.df.bus.map(bus_map)] if len(items) == 0 or c.pnl.p.empty: @@ -267,9 +264,7 @@ def calculate_supply(n, label, supply): supply.loc[idx[raw_index], label] = s.values for c in n.iterate_components(n.branch_components): - for end in ["0", "1"]: - items = c.df.index[c.df["bus" + end].map(bus_map)] if len(items) == 0 or c.pnl["p" + end].empty: @@ -298,7 +293,6 @@ def calculate_supply_energy(n, label, supply_energy): load_types = n.buses.carrier.unique() for i in load_types: - buses = n.buses.query("carrier == @i").index bus_map = pd.Series(False, index=n.buses.index) @@ -306,7 +300,6 @@ def calculate_supply_energy(n, label, supply_energy): bus_map.loc[buses] = True for c in n.iterate_components(n.one_port_components): - items = c.df.index[c.df.bus.map(bus_map)] if len(items) == 0 or c.pnl.p.empty: @@ -327,9 +320,7 @@ def calculate_supply_energy(n, label, supply_energy): supply_energy.loc[idx[raw_index], label] = s.values for c in n.iterate_components(n.branch_components): - for end in ["0", "1"]: - items = c.df.index[c.df["bus" + end].map(bus_map)] if len(items) == 0 or c.pnl["p" + end].empty: @@ -431,7 +422,6 @@ def calculate_weighted_prices(n, label, weighted_prices): } for carrier in link_loads: - if carrier == "electricity": suffix = "" elif carrier[:5] == "space": @@ -454,7 +444,6 @@ def calculate_weighted_prices(n, label, weighted_prices): load = n.loads_t.p_set[buses] for tech in link_loads[carrier]: - names = n.links.index[n.links.index.to_series().str[-len(tech) :] == tech] if names.empty: diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 7aa7a732..a4216450 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -324,7 +324,6 @@ def simplify_links(n, costs, config, output, aggregation_strategies=dict()): ) for lbl in labels.value_counts().loc[lambda s: s > 2].index: - for b, buses, links in split_links(labels.index[labels == lbl]): if len(buses) <= 2: continue