Skip to content

docs(pypsa): the pypsa spec names its repeated row conditions as masks, and its topic files read them under given: masks: - #825

Merged
FBumann merged 2 commits into
claude/trusting-allen-xp0tgbfrom
docs/pypsa-masks
Oct 2, 2026
Merged

FBumann merged 2 commits into
claude/trusting-allen-xp0tgbfrom
docs/pypsa-masks

Conversation

@FBumann

@FBumann FBumann commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Prompt: Lets add this as a feature, and leverage it in the pypsa examples etc! … Push it

Note

The following content was generated by AI.

examples/pypsa.yaml names 16 row conditions it wrote out at every row as masks. They replace parts of 165 where strings, and no row changes. The topic files read them under given: masks:. Stacked on #821.

# before: one of six ramp rows per committable class
where: >-
  Generator_committable AND Generator_p_nom_extendable AND NOT (Generator_p_nom_mod > 0)
  AND (Generator_ramp_limit_up OR Generator_ramp_limit_start_up)
  AND (position(snapshot, by=snapshot_period, within=period) > 0 OR (position(snapshot) == 0 AND (Generator_status_initial == 0 OR Generator_p_init)))
  AND Generator_active
# after
where: >-
  Generator_com_ext
  AND (Generator_ramp_limit_up OR Generator_ramp_limit_start_up)
  AND Generator_ramps_from_previous
The masks, the equivalence check, gate output, what is not done

The masks

Each one is named after the PyPSA row class it selects. "Uses" counts the sites that read it.

Mask Body Uses
C_committed (C = Generator, Link, Process) C_committable AND C_active 26 each
C_com_ext committable, extendable, not modular, active (PyPSA's com-ext rows) 8 each
C_maint_ext maintainable, extendable, not committable and modular, active 5 each
C_ramps_from_previous a snapshot whose ramp reads a previous output 6 each
StorageUnit_fix, StorageUnit_ext fixed or extendable build, active 6 each
Line_lossy, Transformer_lossy transmission_losses AND C_active 4 each

The symbol table spells them in the file's style: \mathrm{on}^{qualifier} with the class letter, and \mathrm{prev} for the ramp masks.

Equivalence

I loaded the file before and after. I expanded each mask into its predicate and compared the flattened conjunct sets of every where. All 352 declarations and every cased expression's regions match.

The split

  • tools/pypsa_split.py puts each mask in the topic its name names. Model.frames() reads mask frames, so a topic that reads another topic's mask states it under given: masks: with that frame. For example, generator_ramping reads Generator_com_ext from generator_commitment.
  • tools/gallery.py includes masks and given masks in each page's symbol cut. The gallery is regenerated.

Gates

  • pixi run lint: clean.
  • pixi run test: 2662 passed.
  • pixi run python -m tools.pypsa_split check examples/pypsa: "24/24 fragments load alone", "the merged fragments and the one file have one canonical form".
  • Not run: compile-tex, because the tectonic bundle does not download here, and this PR touches examples/. docs-build, because the proxy blocks an inventory fetch. CI runs both.

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_01PBmqeqBrqpQC6MVoSrguHK

…s, and its topic files read them under given: masks:

Sixteen masks name the conditions examples/pypsa.yaml wrote out at every
row: per committable class C, C_committed (26 sites), C_com_ext (8),
C_maint_ext (5) and C_ramps_from_previous (6); StorageUnit_fix and _ext
(6 each); Line_lossy and Transformer_lossy (4 each). 165 where strings
change. Each where, with every mask expanded, equals the one it
replaces: 352 declarations and every cased expression were compared
conjunct by conjunct.

tools/pypsa_split.py places a mask in the topic its name names and
writes given: masks: for every other topic that reads it. All 24
fragments load alone and merge to the one file's canonical form. The
symbol table spells the masks as on^{qualifier} and prev, and the
gallery's table cut includes masks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PBmqeqBrqpQC6MVoSrguHK
@FBumann
FBumann requested a review from brynpickering as a code owner October 1, 2026 16:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PBmqeqBrqpQC6MVoSrguHK
@read-the-docs-community

read-the-docs-community Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

@FBumann
FBumann changed the base branch from claude/trusting-allen-xp0tgb to refactor/named-expression October 2, 2026 06:50
@FBumann
FBumann added this pull request to stack #823 October 2, 2026 06:50
@FBumann
FBumann removed this pull request from stack #823 October 2, 2026 06:51
@FBumann
FBumann changed the base branch from refactor/named-expression to claude/trusting-allen-xp0tgb October 2, 2026 06:51
@FBumann
FBumann merged commit ed5622f into claude/trusting-allen-xp0tgb Oct 2, 2026
11 of 12 checks passed
FBumann pushed a commit that referenced this pull request Oct 2, 2026
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.

2 participants