Skip to content

Commit

Permalink
Implement rebuild_selector: easy cases
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielKS committed Jan 15, 2025
1 parent ccd77da commit 9b2fc0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/PowerSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ export DynamicallyGroupedComponentSelector
export subtype_to_string
export component_to_qualified_string
export make_selector
export rebuild_selector
export get_groups
export get_available_groups
#################################################################################
Expand Down Expand Up @@ -629,7 +630,8 @@ import InfrastructureSystems:
component_to_qualified_string,
subtype_to_string,
COMPONENT_NAME_DELIMITER,
make_selector
make_selector,
rebuild_selector
import InfrastructureSystems:
ValueCurve,
InputOutputCurve,
Expand Down
19 changes: 19 additions & 0 deletions test/test_component_selector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,22 @@ end
length(get_available_components(ThermalStandard, test_sys2)) ==
length(get_components(get_available, ThermalStandard, test_sys2))
end

@testset "Test rebuild_selector" begin
@assert !(PSY.NameComponentSelector <: PSY.DynamicallyGroupedComponentSelector)
@assert PSY.TopologyComponentSelector <: PSY.DynamicallyGroupedComponentSelector

sel1::PSY.NameComponentSelector =
make_selector(ThermalStandard, "Component1"; name = "oldname")
sel2::PSY.TopologyComponentSelector =
make_selector(ThermalStandard, Area, "1"; groupby = :all)

@test rebuild_selector(sel1; name = "newname") ==
make_selector(ThermalStandard, "Component1"; name = "newname")
@test_throws Exception rebuild_selector(sel1; groupby = :each)

@test rebuild_selector(sel2; name = "newname") ==
make_selector(ThermalStandard, Area, "1"; name = "newname", groupby = :all)
@test rebuild_selector(sel2; name = "newname", groupby = :each) ==
make_selector(ThermalStandard, Area, "1"; name = "newname", groupby = :each)
end

0 comments on commit 9b2fc0b

Please sign in to comment.