From 2a8cd2ad1f45004407e40750b5e36697c971e2ed Mon Sep 17 00:00:00 2001 From: Saket Date: Tue, 14 Apr 2026 15:15:55 +0200 Subject: [PATCH 1/2] Fix undefined variable in check_scenario_profile and trailing commas in fix() calls --- src/checks.jl | 2 +- src/constraint_functions.jl | 2 +- src/data_functions.jl | 2 +- test/test_checks.jl | 11 +++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/checks.jl b/src/checks.jl index 2a5f8a3f..e9282815 100644 --- a/src/checks.jl +++ b/src/checks.jl @@ -798,7 +798,7 @@ function check_scenario_profile(time_profile::TimeProfile, message::String) bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc) end end - return bool_scp + return bool_osc end function check_osc_sub_profile(sub_profile::TimeProfile, sub_msg::String, bool_scp::Bool) @assert_or_log( diff --git a/src/constraint_functions.jl b/src/constraint_functions.jl index 2b6f1015..4e1b352b 100644 --- a/src/constraint_functions.jl +++ b/src/constraint_functions.jl @@ -638,7 +638,7 @@ function constraints_opex_fixed(m, n::Sink, ๐’ฏแดตโฟแต›, modeltype::EnergyMode # Fix the fixed OPEX for t_inv โˆˆ ๐’ฏแดตโฟแต› - fix(m[:opex_fixed][n, t_inv], 0, ; force = true) + fix(m[:opex_fixed][n, t_inv], 0; force = true) end end diff --git a/src/data_functions.jl b/src/data_functions.jl index c13cb799..181d2725 100644 --- a/src/data_functions.jl +++ b/src/data_functions.jl @@ -33,7 +33,7 @@ function constraints_ext_data(m, n::Node, ๐’ฏ, ๐’ซ, modeltype::EnergyModel, da # Fix the other emissions to 0 to avoid problems with unconstrained variables for t โˆˆ ๐’ฏ, p_em โˆˆ ๐’ซแต‰แต - fix(m[:emissions_node][n, t, p_em], 0, ; force = true) + fix(m[:emissions_node][n, t, p_em], 0; force = true) end end function constraints_ext_data(m, n::Node, ๐’ฏ, ๐’ซ, modeltype::EnergyModel, data::EmissionsProcess) diff --git a/test/test_checks.jl b/test/test_checks.jl index 7dbb105d..99d6278c 100644 --- a/test/test_checks.jl +++ b/test/test_checks.jl @@ -498,6 +498,17 @@ end @test_throws AssertionError EMB.check_scenario_profile(tp, "") end + # Check that valid profiles pass check_scenario_profile without error + valid_profiles = [ + FixedProfile(5), + StrategicProfile([FixedProfile(5)]), + StrategicProfile([RepresentativeProfile([FixedProfile(5)])]), + RepresentativeProfile([ScenarioProfile([FixedProfile(5)])]), + ] + for tp โˆˆ valid_profiles + @test EMB.check_scenario_profile(tp, "") == true + end + # Reactivate logging EMB.ASSERTS_AS_LOG = true end From bf639a251d980fbf94c7bff0dab6b812135fae70 Mon Sep 17 00:00:00 2001 From: Saket Date: Tue, 14 Apr 2026 15:57:43 +0200 Subject: [PATCH 2/2] Addressing the PR review comments --- NEWS.md | 6 ++++++ src/checks.jl | 18 +++++++++--------- test/test_checks.jl | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index e74248c5..6d5e295d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # Release notes +## Unversioned + +### Bug fixes + +* Fixed a bug in the function `check_scenario_profile` resulting in an error, if utilized. + ## Version 0.10.0 (2026-04-09) ### Breaking changes diff --git a/src/checks.jl b/src/checks.jl index e9282815..07e5b01e 100644 --- a/src/checks.jl +++ b/src/checks.jl @@ -750,28 +750,28 @@ scenario indexing. """ function check_scenario_profile(time_profile::TimeProfile, message::String) # Check on the highest level - bool_osc = check_osc_sub_profile(time_profile, message, true) + bool_scp = check_osc_sub_profile(time_profile, message, true) # Iterate through the strategic profiles, if existing if isa(time_profile, StrategicProfile) for l1_profile โˆˆ time_profile.vals sub_msg = "in strategic profiles " * message - bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp) if isa(l1_profile, RepresentativeProfile) for l2_profile โˆˆ l1_profile.vals sub_msg = "in representative profiles in strategic profiles " * message - bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp) if isa(l2_profile, ScenarioProfile) for l3_profile โˆˆ l2_profile.vals sub_msg = "in scenario profiles in representative profiles in strategic profiles " * message - bool_osc = check_osc_sub_profile(l3_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l3_profile, sub_msg, bool_scp) end end end elseif isa(l1_profile, ScenarioProfile) for l2_profile โˆˆ l1_profile.vals sub_msg = "in scenario profiles in strategic profiles " * message - bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp) end end end @@ -781,11 +781,11 @@ function check_scenario_profile(time_profile::TimeProfile, message::String) if isa(time_profile, RepresentativeProfile) for l1_profile โˆˆ time_profile.vals sub_msg = "in representative profiles " * message - bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp) if isa(l1_profile, ScenarioProfile) for l2_profile โˆˆ l1_profile.vals sub_msg = "in scenario profiles in representative profiles " * message - bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp) end end end @@ -795,10 +795,10 @@ function check_scenario_profile(time_profile::TimeProfile, message::String) if isa(time_profile, ScenarioProfile) for l1_profile โˆˆ time_profile.vals sub_msg = "in scenario profiles " * message - bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc) + bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp) end end - return bool_osc + return bool_scp end function check_osc_sub_profile(sub_profile::TimeProfile, sub_msg::String, bool_scp::Bool) @assert_or_log( diff --git a/test/test_checks.jl b/test/test_checks.jl index 99d6278c..0c8ef8c9 100644 --- a/test/test_checks.jl +++ b/test/test_checks.jl @@ -506,7 +506,7 @@ end RepresentativeProfile([ScenarioProfile([FixedProfile(5)])]), ] for tp โˆˆ valid_profiles - @test EMB.check_scenario_profile(tp, "") == true + @test EMB.check_scenario_profile(tp, "") end # Reactivate logging