Skip to content

Fix bug: Transformer type handling in stochastic networks#1499

Merged
lkstrp merged 7 commits intomasterfrom
patch-trafotypes
Dec 22, 2025
Merged

Fix bug: Transformer type handling in stochastic networks#1499
lkstrp merged 7 commits intomasterfrom
patch-trafotypes

Conversation

@Irieo
Copy link
Copy Markdown
Contributor

@Irieo Irieo commented Dec 19, 2025

Closes #1496

Changes proposed in this Pull Request

When using transformer types in stochastic networks, apply_transformer_types() failed with because it was not handling multiindex with scenarios when matching data with transformer_types table.

Fix is to drop scenarios & look at unique transformer types. User changes across type data are caught by the consistency checks.

Small history on this: when preparing #1154 we did think about problem of types broadcasting, and had exactly this fix implemented, which was reverted before merge since we universally agreed types should ideally not be broadcasted with scenarios (w/o re-applying the fix). Problems of this kind will go with #1474

@gincrement thanks for putting attention to this. One question, in your version you've included "tap_ratio" into a copy of transformers data: https://github.com/PyPSA/PyPSA/compare/master...gincrement:pypsa:patch-9?diff=split&w#diff-4d3697f16fbe48a31c279ea3a292649b3c6a62aebe09e837b34c35674af6e30bR484. I don't see a reason for doing this, since tap_ratio is created fresh later in function and not extracted from either table. Do I miss something?

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in docs.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes docs/release-notes.md of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Copy link
Copy Markdown
Member

@lkstrp lkstrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed and as you say: This isn't very clean and quite a hot fix, but let's scrap that all again with #1487 and #1474

@lkstrp lkstrp enabled auto-merge (squash) December 19, 2025 13:58
@lkstrp lkstrp disabled auto-merge December 22, 2025 07:48
@lkstrp lkstrp merged commit cdd71a1 into master Dec 22, 2025
22 checks passed
@lkstrp lkstrp deleted the patch-trafotypes branch December 22, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in stochastic optimization that transformer types are not checked correctily in n.transformer_types

3 participants