Spell per-unit tags out for display; per-column table units - #609
Open
luke-kiernan wants to merge 1 commit into
Open
Spell per-unit tags out for display; per-column table units#609luke-kiernan wants to merge 1 commit into
luke-kiernan wants to merge 1 commit into
Conversation
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>
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.
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 terseDU/SU. Those are convenient shorthand but aren't standard terminology, so verbose output (a component'stext/plaindisplay) spells them out while terse contexts — the one-lineshow, table cells — keep the tags.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'unitskwarg now accepts a column-to-unit mapping (AbstractDictorNamedTuple) 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 owndisplay_units_argdefault rather than inheriting a neighbour's.How
display_stringsplits the old per-marker string into a value part and a base label, which is what lets the base be factored out of aNamedTuple. Column resolution moves the oldunits === nothing ? trait_arg : unitsternary into a small_column_unitsdispatch, so the mapping forms are three methods rather than a branch.🤖 Generated with Claude Code