Skip to content

Commit 6fd95c7

Browse files
authored
Filter demands to prevent 0/0 division error (#794)
* Filter demands to prevent 0/0 division error * Detect dimensions dynamically
1 parent baf447c commit 6fd95c7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/muse/sectors/subsector.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ def aggregate_lp(
8787
timeslice_level=self.timeslice_level,
8888
)
8989

90+
# Further filer demands to only include commodities with positive unmet demand
91+
# Some commodities may be lost here if capacity is already sufficient to meet
92+
# demand
93+
demands = demands.where(
94+
demands.sum([dim for dim in demands.dims if dim != "commodity"]) > 0,
95+
drop=True,
96+
)
97+
9098
if "dst_region" in demands.dims:
9199
msg = """
92100
dst_region found in demand dimensions. This is unexpected. Demands

0 commit comments

Comments
 (0)