Skip to content

Add units-aware getters/setters infrastructure#539

Draft
luke-kiernan wants to merge 7 commits into
mainfrom
lk/units-prototype
Draft

Add units-aware getters/setters infrastructure#539
luke-kiernan wants to merge 7 commits into
mainfrom
lk/units-prototype

Conversation

@luke-kiernan
Copy link
Copy Markdown
Contributor

Prototype of units-aware getters/setters.

  • Add units.jl with Unitful integration, RelativeQuantity type for DU/SU
  • Define custom Mvar and MVA units for reactive/apparent power
  • Update generate_structs.jl template to generate two-method accessors:
    • Default accessor returns natural units (MW, Mvar, etc.)
    • Optional second argument accepts explicit unit (DU, SU, MW, etc.)
  • Add get_natural_unit() to map conversion types to appropriate units (reactive power fields → Mvar, other power fields → MW)
  • Export unit types and Unitful re-exports from main module
  • Register custom Unitful units in init()

luke-kiernan and others added 2 commits March 10, 2026 20:54
- Add units.jl with Unitful integration, RelativeQuantity type for DU/SU
- Define custom Mvar and MVA units for reactive/apparent power
- Update generate_structs.jl template to generate two-method accessors:
  - Default accessor returns natural units (MW, Mvar, etc.)
  - Optional second argument accepts explicit unit (DU, SU, MW, etc.)
- Add get_natural_unit() to map conversion types to appropriate units
  (reactive power fields → Mvar, other power fields → MW)
- Export unit types and Unitful re-exports from main module
- Register custom Unitful units in __init__()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
luke-kiernan and others added 2 commits March 17, 2026 13:24
The type parameter in repr() may or may not be module-qualified
depending on what names are in scope, which differs between local
and CI environments. Use occursin checks instead of exact string
matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.56%. Comparing base (5a1447e) to head (f97505b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/units.jl 0.00% 22 Missing ⚠️
src/cost_aliases.jl 44.44% 5 Missing ⚠️
src/utils/generate_structs.jl 64.28% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
+ Coverage   77.81%   78.56%   +0.74%     
==========================================
  Files          75       75              
  Lines        6680     6628      -52     
==========================================
+ Hits         5198     5207       +9     
+ Misses       1482     1421      -61     
Flag Coverage Δ
unittests 78.56% <33.33%> (+0.74%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/InfrastructureSystems.jl 54.54% <100.00%> (+14.54%) ⬆️
src/value_curve.jl 94.84% <100.00%> (+1.91%) ⬆️
src/cost_aliases.jl 76.08% <44.44%> (-9.28%) ⬇️
src/utils/generate_structs.jl 85.27% <64.28%> (-2.02%) ⬇️
src/units.jl 8.33% <0.00%> (-91.67%) ⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

luke-kiernan and others added 3 commits March 27, 2026 14:49
When exclude_getter is true, generates an internal _get_ prefixed accessor
instead of the public get_ accessor. Suppresses the public getter export
while keeping setter exports (since exclude_setter means hand-written, not
nonexistent).

Used by PSY to make get_base_power return unitful values while keeping
_get_base_power as raw Float64 for internal conversion machinery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The 1-arg getter now uses DEFAULT_UNITS (a constant) instead of the
stateful _get_system_units, eliminating type instability and enabling
full compiler optimization of the getter path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace inline units.jl with using/re-exporting from PowerSystemsUnits.
Keep time_period_conversion in units.jl (unrelated to unit types).

Co-Authored-By: Claude Opus 4.6 (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.

1 participant