Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#965)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)
- [github.com/snakemake/snakefmt: v0.9.0 → v0.10.0](snakemake/snakefmt@v0.9.0...v0.10.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent b0cda78 commit 6bf4b1c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:

# Formatting with "black" coding style
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
# Format Python files
- id: black
Expand All @@ -72,7 +72,7 @@ repos:

# Format Snakemake rule / workflow files
- repo: https://github.com/snakemake/snakefmt
rev: v0.9.0
rev: v0.10.0
hooks:
- id: snakefmt

Expand Down
14 changes: 7 additions & 7 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ rule solve_all_networks:
input:
expand(
"results/" + RDIR + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
**config["scenario"]
**config["scenario"],
),


Expand All @@ -116,7 +116,7 @@ rule plot_all_p_nom:
+ RDIR
+ "plots/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_p_nom.{ext}",
**config["scenario"],
ext=["png", "pdf"]
ext=["png", "pdf"],
),


Expand All @@ -127,7 +127,7 @@ rule make_all_summaries:
+ RDIR
+ "summaries/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}",
**config["scenario"],
country=["all"] + config["countries"]
country=["all"] + config["countries"],
),


Expand All @@ -140,7 +140,7 @@ rule plot_all_summaries:
summary=["energy", "costs"],
**config["scenario"],
country=["all"] + config["countries"],
ext=["png", "pdf"]
ext=["png", "pdf"],
),


Expand Down Expand Up @@ -867,7 +867,7 @@ if config["monte_carlo"]["options"].get("add_to_snakefile", False) == True:
"networks/"
+ RDIR
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{unc}.nc",
**config["scenario"]
**config["scenario"],
),

rule solve_network:
Expand Down Expand Up @@ -912,7 +912,7 @@ if config["monte_carlo"]["options"].get("add_to_snakefile", False) == True:
"results/"
+ RDIR
+ "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{unc}.nc",
**config["scenario"]
**config["scenario"],
),


Expand All @@ -930,7 +930,7 @@ def input_make_summary(w):
**{
k: config["scenario"][k] if getattr(w, k) == "all" else getattr(w, k)
for k in ["simpl", "clusters", "opts"]
}
},
)


Expand Down
6 changes: 3 additions & 3 deletions scripts/build_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ def eez(

# repeat to simplify after the buffer correction
ret_df_new = ret_df_new.map(
lambda x: x
if x is None
else _simplify_polys(x, minarea=minarea, tolerance=tolerance)
lambda x: (
x if x is None else _simplify_polys(x, minarea=minarea, tolerance=tolerance)
)
)
ret_df_new = ret_df_new.apply(lambda x: x if x is None else make_valid(x))

Expand Down
8 changes: 5 additions & 3 deletions scripts/clean_osm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,11 @@ def create_extended_country_shapes(country_shapes, offshore_shapes, tolerance=0.
{
"name": list(country_shapes.index),
"geometry": [
c_geom.unary_union(offshore_shapes[c_code])
if c_code in offshore_shapes
else c_geom
(
c_geom.unary_union(offshore_shapes[c_code])
if c_code in offshore_shapes
else c_geom
)
for c_code, c_geom in country_shapes.items()
],
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/cluster_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ def busmap_for_country(x):
n,
n_cluster_c,
buses_i=x.index,
feature=feature.loc[x.index]
feature=feature.loc[x.index],
# n, n_clusters[x.name], buses_i=x.index, feature=feature.loc[x.index]
)
elif algorithm == "modularity":
return prefix + busmap_by_greedy_modularity(
# TODO Check consistency (fix for TypeError: 'int' object is not subscriptable in case of a single country)
n,
n_cluster_c,
buses_i=x.index
buses_i=x.index,
# n, n_clusters[x.name], buses_i=x.index
)
else:
Expand Down
6 changes: 3 additions & 3 deletions scripts/simplify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ def aggregate_to_substations(n, aggregation_strategies=dict(), buses_i=None):
dijkstra(adj, directed=False, indices=bus_indexer), buses_i, n.buses.index
)

dist[
buses_i
] = np.inf # bus in buses_i should not be assigned to different bus in buses_i
dist[buses_i] = (
np.inf
) # bus in buses_i should not be assigned to different bus in buses_i

# avoid assignment a bus to a wrong country
for c in n.buses.country.unique():
Expand Down
6 changes: 3 additions & 3 deletions scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,9 @@ def solve_network(n, config, opts="", **kwargs):

n = pypsa.Network(snakemake.input[0])
if snakemake.params.augmented_line_connection.get("add_to_snakefile"):
n.lines.loc[
n.lines.index.str.contains("new"), "s_nom_min"
] = snakemake.params.augmented_line_connection.get("min_expansion")
n.lines.loc[n.lines.index.str.contains("new"), "s_nom_min"] = (
snakemake.params.augmented_line_connection.get("min_expansion")
)
n = prepare_network(n, solve_opts)

n = solve_network(
Expand Down

0 comments on commit 6bf4b1c

Please sign in to comment.