Skip to content

Commit dbf38a2

Browse files
authored
Fix undefined variable in check_scenario_profile and trailing commas in fix() calls (#88)
1 parent a409b45 commit dbf38a2

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release notes
22

3+
## Unversioned
4+
5+
### Bug fixes
6+
7+
* Fixed a bug in the function `check_scenario_profile` resulting in an error, if utilized.
8+
39
## Version 0.10.0 (2026-04-09)
410

511
### Breaking changes

src/checks.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -750,28 +750,28 @@ scenario indexing.
750750
"""
751751
function check_scenario_profile(time_profile::TimeProfile, message::String)
752752
# Check on the highest level
753-
bool_osc = check_osc_sub_profile(time_profile, message, true)
753+
bool_scp = check_osc_sub_profile(time_profile, message, true)
754754

755755
# Iterate through the strategic profiles, if existing
756756
if isa(time_profile, StrategicProfile)
757757
for l1_profile time_profile.vals
758758
sub_msg = "in strategic profiles " * message
759-
bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc)
759+
bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp)
760760
if isa(l1_profile, RepresentativeProfile)
761761
for l2_profile l1_profile.vals
762762
sub_msg = "in representative profiles in strategic profiles " * message
763-
bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc)
763+
bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp)
764764
if isa(l2_profile, ScenarioProfile)
765765
for l3_profile l2_profile.vals
766766
sub_msg = "in scenario profiles in representative profiles in strategic profiles " * message
767-
bool_osc = check_osc_sub_profile(l3_profile, sub_msg, bool_osc)
767+
bool_scp = check_osc_sub_profile(l3_profile, sub_msg, bool_scp)
768768
end
769769
end
770770
end
771771
elseif isa(l1_profile, ScenarioProfile)
772772
for l2_profile l1_profile.vals
773773
sub_msg = "in scenario profiles in strategic profiles " * message
774-
bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc)
774+
bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp)
775775
end
776776
end
777777
end
@@ -781,11 +781,11 @@ function check_scenario_profile(time_profile::TimeProfile, message::String)
781781
if isa(time_profile, RepresentativeProfile)
782782
for l1_profile time_profile.vals
783783
sub_msg = "in representative profiles " * message
784-
bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc)
784+
bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp)
785785
if isa(l1_profile, ScenarioProfile)
786786
for l2_profile l1_profile.vals
787787
sub_msg = "in scenario profiles in representative profiles " * message
788-
bool_osc = check_osc_sub_profile(l2_profile, sub_msg, bool_osc)
788+
bool_scp = check_osc_sub_profile(l2_profile, sub_msg, bool_scp)
789789
end
790790
end
791791
end
@@ -795,7 +795,7 @@ function check_scenario_profile(time_profile::TimeProfile, message::String)
795795
if isa(time_profile, ScenarioProfile)
796796
for l1_profile time_profile.vals
797797
sub_msg = "in scenario profiles " * message
798-
bool_osc = check_osc_sub_profile(l1_profile, sub_msg, bool_osc)
798+
bool_scp = check_osc_sub_profile(l1_profile, sub_msg, bool_scp)
799799
end
800800
end
801801
return bool_scp

src/constraint_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ function constraints_opex_fixed(m, n::Sink, 𝒯ᴵⁿᵛ, modeltype::EnergyMode
638638

639639
# Fix the fixed OPEX
640640
for t_inv 𝒯ᴵⁿᵛ
641-
fix(m[:opex_fixed][n, t_inv], 0, ; force = true)
641+
fix(m[:opex_fixed][n, t_inv], 0; force = true)
642642
end
643643
end
644644

src/data_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function constraints_ext_data(m, n::Node, 𝒯, 𝒫, modeltype::EnergyModel, da
3333

3434
# Fix the other emissions to 0 to avoid problems with unconstrained variables
3535
for t 𝒯, p_em 𝒫ᵉᵐ
36-
fix(m[:emissions_node][n, t, p_em], 0, ; force = true)
36+
fix(m[:emissions_node][n, t, p_em], 0; force = true)
3737
end
3838
end
3939
function constraints_ext_data(m, n::Node, 𝒯, 𝒫, modeltype::EnergyModel, data::EmissionsProcess)

test/test_checks.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,17 @@ end
498498
@test_throws AssertionError EMB.check_scenario_profile(tp, "")
499499
end
500500

501+
# Check that valid profiles pass check_scenario_profile without error
502+
valid_profiles = [
503+
FixedProfile(5),
504+
StrategicProfile([FixedProfile(5)]),
505+
StrategicProfile([RepresentativeProfile([FixedProfile(5)])]),
506+
RepresentativeProfile([ScenarioProfile([FixedProfile(5)])]),
507+
]
508+
for tp valid_profiles
509+
@test EMB.check_scenario_profile(tp, "")
510+
end
511+
501512
# Reactivate logging
502513
EMB.ASSERTS_AS_LOG = true
503514
end

0 commit comments

Comments
 (0)