Fix/ego 213 pv rooftop building id duplicate bus - #748
Open
joda9 wants to merge 3 commits into
Open
Conversation
0.3.0 was published on 2026-08-03 (daf14ab set the date, the tag and the PyPI upload followed), so its changelog section describes a released artifact and must not keep growing. Every change landing on dev now belongs to the next release. Adds `doc/whatsnew/v0-3-1.rst` and includes it above 0.3.0 in `doc/whatsnew.rst`, so the newest section stays at the top of the rendered page. Moves the one entry that had already been appended to 0.3.0 after the release: the `config_opf_julia.cfg` Julia version correction from 1d2b5de, committed at 14:44 on the day the release date was set at 09:08. It documents a change that is not in the 0.3.0 artifact, so readers comparing the changelog against the released package would not find it. `Release date: not yet released` is a placeholder; it gets stamped the way daf14ab did for 0.3.0 when 0.3.1 is published.
Importing generators failed for some grids with
ValueError: cannot reindex on an axis with duplicate labels
raised from `gens_df.update()` in `_integrate_pv_rooftop`
(openego/eGo#213, reported for MV grids 33084 and 33695).
The function derived a bus -> building ID map from the conventional loads.
That map was deduplicated on "building_id" but indexed by "bus", so a bus
carrying the loads of two different buildings kept both rows and produced a
duplicated bus label. `gens_df.loc[:, ["bus"]].join(..., on="bus")` then
emitted two rows per generator, and `DataFrame.update` reindexes its argument
onto `self.index`, which rejects a non-unique index.
The map is not repaired here, it is removed, because it has had no effect on
the result for two and a half years. It was introduced in ae00203 to supply
the key for matching existing PV rooftop plants against the scenario data,
which merged `on="building_id"` at the time; the generators in a ding0
topology carry no building ID, so one was guessed from the conventional load
sitting at the same bus. A ToDo above the block already asked for the match
to use the unique MaStR source ID instead. d33e851 did exactly that and
removed the ToDo, but left the map behind.
Since then the guessed value has been discarded: `gens_existing` is merged
with `pv_rooftop_df` on "source_id" with `suffixes=("_old", "")`, so the
building ID written back to `generators_df` comes from the scenario data and
the guessed one survives only as the unread column `building_id_old`. Every
PV rooftop generator is either decommissioned and removed, or matched and
updated from the scenario, so there is no path on which the guess is read.
Setting the building ID of all 2472 conventional loads in the test grid to a
sentinel value changes nothing about the generators the function produces,
and `generators_df` is byte-identical with and without the block. Fixing the
deduplication would therefore have preserved a computation whose only
remaining observable behaviour was this crash.
`loads_df` was read for the map alone, so the function no longer touches the
loads at all.
The regression test is kept as a guard against reintroducing a per-bus load
lookup. The shipped test grid cannot produce the situation on its own: it has
70 buses with more than one conventional load, but all of them share a single
building ID, so the second building is added explicitly. The test fails on dev
with the exact error above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the change and which issue is fixed.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Checklist:
pre-commithooks