Skip to content
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

Remove duplicate check #1055

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1415,10 +1415,31 @@ function check(sys::System)
buscheck(buses)
critical_components_check(sys)
adequacy_check(sys)
check_components(sys)
check_subsystems(sys)
return
end

"""
Check the the consistency of subsystems.
"""
function check_subsystems(sys::System)
must_be_assigned_to_subsystem = false
for (i, component) in enumerate(iterate_components(sys))
is_assigned = is_assigned_to_subsystem(sys, component)
if i == 1
must_be_assigned_to_subsystem = is_assigned
elseif is_assigned != must_be_assigned_to_subsystem
throw(
IS.InvalidValue(
"If any component is assigned to a subsystem then all " *
"components must be assigned to a subsystem.",
),
)
end
check_subsystems(sys, component)
end
end

"""
Check the values of all components. See [`check_component`](@ref) for exceptions thrown.
"""
Expand All @@ -1437,7 +1458,6 @@ function check_components(sys::System; check_masked_components = true)
)
end
check_component(sys, component)
check_subsystems(sys, component)
end

if check_masked_components
Expand Down
1 change: 1 addition & 0 deletions test/test_validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ end
bad_therm_gen_act_power = thermal_generators5(nodes)
bad_therm_gen_act_power[1].active_power = 10
nodes = nodes5()
# This is an explicit check for one error message.
@test_logs (:warn, r"Invalid range") System(
100.0,
nodes,
Expand Down
Loading