-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement convert_component! for StandardLoad <- PowerLoad #1022
Conversation
- Define convert_component! for conversions from PowerLoad to StandardLoad - Add unit tests for this method along the lines of existing convert_component! unit tests - Refactor convert_component! unit tests to remove repetition
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1022 +/- ##
=======================================
Coverage 85.37% 85.37%
=======================================
Files 169 169
Lines 7639 7646 +7
=======================================
+ Hits 6522 6528 +6
- Misses 1117 1118 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
src/base.jl
Outdated
function convert_component!( | ||
new_type::Type{StandardLoad}, | ||
old_load::PowerLoad, | ||
sys::System; | ||
kwargs..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Julia the argument after the !
is the one being modified. In this case is the system that is being changed.
function convert_component!( | |
new_type::Type{StandardLoad}, | |
old_load::PowerLoad, | |
sys::System; | |
kwargs..., | |
function convert_component!( | |
sys::System, | |
old_load::PowerLoad | |
new_type::Type{StandardLoad}, | |
; | |
kwargs..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing convert_component!
methods have the new type as the first argument, then the old component, then the system:
Lines 1922 to 1927 in 1b7c1c0
function convert_component!( | |
linetype::Type{MonitoredLine}, | |
line::Line, | |
sys::System; | |
kwargs..., | |
) |
Lines 1956 to 1961 in 1b7c1c0
function convert_component!( | |
linetype::Type{Line}, | |
line::MonitoredLine, | |
sys::System; | |
kwargs..., | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I should. Fixed in 703762a.
test/test_powersystemconstructors.jl
Outdated
@@ -132,26 +132,51 @@ end | |||
end | |||
|
|||
@testset "Test component conversion" begin | |||
test_conversion = | |||
# Reusable resources for this testset | |||
load_test_system = () -> System(joinpath(BAD_DATA, "case5_re.m")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PSB here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9c7ef0f, reverted the old test and now use PSB for the new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes are required.
test/test_powersystemconstructors.jl
Outdated
ta = TimeSeries.TimeArray(dates, data, [component_name]) | ||
time_series = SingleTimeSeries(; name = ts_name, data = ta) | ||
add_time_series!(sys, old_component, time_series) | ||
@test get_time_series(SingleTimeSeries, old_component, ts_name) isa SingleTimeSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test get_time_series(SingleTimeSeries, old_component, ts_name) isa SingleTimeSeries | |
@test get_time_series(SingleTimeSeries, old_component, ts_name) isa | |
SingleTimeSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 703762a
test/test_powersystemconstructors.jl
Outdated
new_component = get_component(StandardLoad, sys, component_name) | ||
@test !isnothing(new_component) | ||
@test get_name(new_component) == component_name | ||
@test get_time_series(SingleTimeSeries, new_component, ts_name) isa SingleTimeSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test get_time_series(SingleTimeSeries, new_component, ts_name) isa SingleTimeSeries | |
@test get_time_series(SingleTimeSeries, new_component, ts_name) isa | |
SingleTimeSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 703762a
test/test_powersystemconstructors.jl
Outdated
@test get_time_series(SingleTimeSeries, new_component, ts_name) isa SingleTimeSeries | ||
# Conversion back is not implemented | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 703762a
- For all non-deprecated convert_component! methods, use the argument order: system, old component, new component type - Deprecate old convert_component! methods for backwards compatibility - Test deprecation - Run formatter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GabrielKS you need to run the formatter
This will be used for a new system in PowerSystemCaseBuilder. Includes unit tests.