Skip to content

Commit 3d8f908

Browse files
committed
Improve test for different bound types
1 parent 7b733f6 commit 3d8f908

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

Diff for: message_ix/tests/test_feature_price_emission.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,22 @@ def test_custom_type_variable_periodlength(test_mp, request):
332332
npt.assert_allclose(obs, exp)
333333

334334

335+
bound = 0.2
336+
cumulative = False
337+
years = [2020, 2021, 2022, 2023]
338+
tag = "yearly_" + str(bound) + "_equal"
335339
@pytest.mark.parametrize(
336-
"cumulative_bound, years",
340+
"bound, cumulative, years, tag",
337341
[
338-
(2.5, [2020, 2030, 2040, 2050]),
339-
(0.25, [2020, 2025, 2030, 2040, 2050]),
340-
(0.50, [2020, 2030, 2040, 2050]),
341-
(0.50, [2020, 2025, 2030, 2040, 2050]),
342-
(0.75, [2020, 2030, 2040, 2050]),
343-
(0.75, [2020, 2025, 2030, 2040, 2050]),
342+
(0.25, True, [2020, 2030, 2040, 2050], "0.25_equal"),
343+
(0.25, True, [2020, 2025, 2030, 2040, 2050], "0.25_varying"),
344+
(0.50, True, [2020, 2030, 2040, 2050], "0.5_equal"),
345+
(0.50, True, [2020, 2025, 2030, 2040, 2050], "0.5_varying"),
346+
(0.75, True, [2020, 2030, 2040, 2050], "0.75_equal"),
347+
(0.75, True, [2020, 2025, 2030, 2040, 2050], "0.75_varying"),
344348
],
345349
)
346-
def test_price_duality(test_mp, request, cumulative_bound, years):
350+
def test_price_duality(test_mp, request, bound, cumulative, years, tag):
347351
# set up a scenario for cumulative constraints
348352
scen = Scenario(
349353
test_mp,
@@ -352,13 +356,15 @@ def test_price_duality(test_mp, request, cumulative_bound, years):
352356
version="new",
353357
)
354358
model_setup(scen, years, simple_tecs=False)
355-
scen.add_cat("year", "cumulative", years)
356-
scen.add_par(
357-
"bound_emission",
358-
["World", "GHG", "all", "cumulative"],
359-
cumulative_bound,
360-
"tCO2",
361-
)
359+
if cumulative:
360+
scen.add_cat("year", "cumulative", years)
361+
scen.add_par(
362+
"bound_emission", ["World", "ghg", "all", "cumulative"], bound, "tCO2",
363+
)
364+
else:
365+
for y in years:
366+
scen.add_cat("year", y, y)
367+
scen.add_par("bound_emission", ["World", "ghg", "all", y], bound, "tCO2")
362368
scen.commit("initialize test scenario")
363369
scen.solve(quiet=True, **solve_args)
364370

0 commit comments

Comments
 (0)