temoa
temoa copied to clipboard
Bug: seasonal storage indices use dict keys instead of values in flows.py
Description
A bug was identified in temoa/components/flows.py in the create_commodity_balance_and_flow_sets function around lines 181-188.
The set comprehension for M.seasonalStorageLevelIndices_rpstv iterates over M.sequential_to_season as keys only, binding s_stor to the sequence key instead of the mapped seasonal value. The iteration should use .items() to properly unpack both the key and value.
Current Code
M.seasonalStorageLevelIndices_rpstv = {
(r, p, s_stor, t, v)
for r, p, t in M.storageVintages
if t in M.tech_seasonal_storage
for v in M.storageVintages[r, p, t]
for _p, s_stor in M.sequential_to_season
if _p == p
}
Expected Behavior
The iteration should use .items() to bind the dict key to (_p, s_seq) and the value to s (or s_stor), ensuring the season index comes from the dict value rather than its key.
References
- Pull Request: https://github.com/TemoaProject/temoa/pull/165
- Original Comment: https://github.com/TemoaProject/temoa/pull/165#discussion_r2441112094
- Reported by: @ParticularlyPythonicBS