Replace SystemUnitsSettings with a plain Float64 units anchor#596
Open
luke-kiernan wants to merge 3 commits into
Open
Replace SystemUnitsSettings with a plain Float64 units anchor#596luke-kiernan wants to merge 3 commits into
luke-kiernan wants to merge 3 commits into
Conversation
The unit_system field on SystemUnitsSettings was a leftover from the
stateful-units era: it made the struct mutable and shared by reference
across every attached component so a system-wide unit change would
propagate instantly, but that whole mechanism is being retired (see
matching PowerSystems.jl change). The only thing components genuinely
need is the system's base power, a plain number that never changes
after construction.
InfrastructureSystemsInternal.units_info is now Union{Nothing, Float64}.
get_units_info/set_units_info! are renamed get_base_value/set_base_value!
and gain a generic default (get_base_value(x) = get_base_value(get_internal(x)))
so any type implementing get_internal picks it up for free, and a type
that stores its own anchor directly (no InfrastructureSystemsInternal)
can add one small concrete method instead of a parallel mechanism.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## IS4 #596 +/- ##
==========================================
+ Coverage 83.99% 84.14% +0.15%
==========================================
Files 73 73
Lines 6334 6327 -7
==========================================
+ Hits 5320 5324 +4
+ Misses 1014 1003 -11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- Constrain get_base_value/set_base_value! generic fallback to InfrastructureSystemsType, matching the get_uuid convention, so it doesn't dispatch on unrelated types that happen to define get_internal. - Add test coverage for the generic get_internal-forwarding path via a minimal mock type, not just the InfrastructureSystemsInternal-direct methods. - Fix an @extref reference in write_a_tutorial.md that got mangled into invalid :doc: role syntax during the units_info->base_value rename commit; restore the working label-based reference. Co-Authored-By: Claude Sonnet 5 <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.
Remove the final pieces of the stateful units system. In
InfrastructureSystemsInternal, the shared referenceunits_info:: SystemUnitsSettingis now replaced bybase_value::Union{Nothing, Float64}: the system's base power for an attached component,nothingfor an unattached component.get_base_value/set_base_value!have a generic default which forwards to theinternalfield, so components get their "system base" anchor for free.@m-bossart Your
TransformerCircuitcan now carry its ownbase_value::Union{Nothing, Float64}and overrideIS. {get, set}_base_value{!}. The units plumbing will work appropriately. The code to keep thatbase_valuefield up-to-date still lands in PSY, though, which seems mildly clunky. This is the best I can come up with, though.