Skip to content

Spell per-unit tags out for display; per-column table units - #609

Open
luke-kiernan wants to merge 1 commit into
IS4from
lk/display-units-1753
Open

Spell per-unit tags out for display; per-column table units#609
luke-kiernan wants to merge 1 commit into
IS4from
lk/display-units-1753

Conversation

@luke-kiernan

Copy link
Copy Markdown
Contributor

What changed

Two display-side changes that PowerSystems.jl#1753 needs. Paired with the PSY PR that consumes them.

  • display_string(x) renders a value with its relative-unit tag spelled out instead of the terse DU/SU. Those are convenient shorthand but aren't standard terminology, so verbose output (a component's text/plain display) spells them out while terse contexts — the one-line show, table cells — keep the tags.

    0.6 * DU                          → "0.6 p.u. in device base"
    (min = 0.0 * SU, max = 2.5 * SU)  → "(min = 0.0 p.u., max = 2.5 p.u.) in system base"
    

    A compound field whose elements share one base states it once, after the tuple. Mixed or partially-tagged tuples have nothing to hoist, so they fall back to spelling each element out.

  • show_components' units kwarg now accepts a column-to-unit mapping (AbstractDict or NamedTuple) as well as a single unit, so one table can show one column in natural units and another in device base. A column absent from the mapping keeps its own display_units_arg default rather than inheriting a neighbour's.

How

display_string splits the old per-marker string into a value part and a base label, which is what lets the base be factored out of a NamedTuple. Column resolution moves the old units === nothing ? trait_arg : units ternary into a small _column_units dispatch, so the mapping forms are three methods rather than a branch.

🤖 Generated with Claude Code

Two display-side changes PowerSystems needs for its `display(component)`
output (Sienna-Platform/PowerSystems.jl#1753):

- `display_string` renders a value with its relative-unit tag spelled out
  ("0.6 p.u. in device base") instead of the terse "0.6 DU". `DU`/`SU` are
  convenient shorthand but are not standard terminology, so verbose output
  spells them out while terse contexts keep the tags. It recurses into
  NamedTuples so compound fields print element-wise.
- `show_components`' `units` kwarg now accepts a column-to-unit mapping
  (`AbstractDict` or `NamedTuple`) in addition to a single unit, so a table
  can show one column in MW and another in device base. Columns absent from
  the mapping keep their own `display_units_arg` default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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