Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 10, 2025
1 parent 1eb3b34 commit 2b388a8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/build_bus_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,16 @@ def get_gadm_shape(
n.determine_network_topology()
non_isolated_buses = n.buses.duplicated(subset=["sub_network"], keep=False)
isolated_buses = n.buses[~non_isolated_buses].index
non_isolated_regions = onshore_regions[~onshore_regions.name.isin(isolated_buses)]
non_isolated_regions = onshore_regions[
~onshore_regions.name.isin(isolated_buses)
]
isolated_regions = onshore_regions[onshore_regions.name.isin(isolated_buses)]

# Combine regions while prioritizing non-isolated ones
onshore_regions = (
pd.concat([non_isolated_regions, isolated_regions])
.drop_duplicates("shape_id", keep="first")
)

onshore_regions = pd.concat(
[non_isolated_regions, isolated_regions]
).drop_duplicates("shape_id", keep="first")

if len(onshore_regions) < len(gadm_country):
logger.warning(
f"The number of remaining of buses are less than the number of administrative clusters suggested!"
Expand Down

0 comments on commit 2b388a8

Please sign in to comment.