From efd35f75c45dbc8811d389084d1a2b430f722a28 Mon Sep 17 00:00:00 2001 From: Behnam Zakeri Date: Thu, 11 Apr 2024 14:07:11 +0200 Subject: [PATCH] Apply ruff format for parameterizing tests --- .../tests/test_feature_price_emission.py | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/message_ix/tests/test_feature_price_emission.py b/message_ix/tests/test_feature_price_emission.py index fdd4b13b8..642123180 100644 --- a/message_ix/tests/test_feature_price_emission.py +++ b/message_ix/tests/test_feature_price_emission.py @@ -202,17 +202,18 @@ def test_custom_type_variable_periodlength(test_mp, request): npt.assert_allclose(obs, exp) + @pytest.mark.parametrize( "cumulative_bound, years, tag", - ( + [ (0.25, [2020, 2030, 2040, 2050], "0.25_equal"), (0.25, [2020, 2025, 2030, 2040, 2050], "0.25_varying"), - (0.50, [2020, 2030, 2040, 2050], "0.5_equal") - (0.50, [2020, 2025, 2030, 2040, 2050], "0.5_varying") - (0.75, [2020, 2030, 2040, 2050], "0.75_equal") + (0.50, [2020, 2030, 2040, 2050], "0.5_equal"), + (0.50, [2020, 2025, 2030, 2040, 2050], "0.5_varying"), + (0.75, [2020, 2030, 2040, 2050], "0.75_equal"), (0.75, [2020, 2025, 2030, 2040, 2050], "0.75_varying"), - ) - ) + ], +) def test_price_duality(test_mp, request, cumulative_bound, years, tag): # set up a scenario for cumulative constraints scen = Scenario(test_mp, MODEL, "cum_many_tecs_" + tag, version="new") @@ -222,7 +223,7 @@ def test_price_duality(test_mp, request, cumulative_bound, years, tag): "bound_emission", ["World", "ghg", "all", "cumulative"], cumulative_bound, - "tCO2" + "tCO2", ) scen.commit("initialize test scenario") scen.solve(quiet=True) @@ -231,9 +232,7 @@ def test_price_duality(test_mp, request, cumulative_bound, years, tag): # Run scenario with `tax_emission` based on `PRICE_EMISSION` # from cumulative constraint scenario. # ---------------------------------------------------------- - tax_scen = Scenario( - test_mp, MODEL, scenario="tax_many_tecs_" + tag, version="new" - ) + tax_scen = Scenario(test_mp, MODEL, scenario="tax_many_tecs_" + tag, version="new") model_setup(tax_scen, years, simple_tecs=False) for y in years: tax_scen.add_cat("year", y, y) @@ -265,9 +264,7 @@ def test_price_duality(test_mp, request, cumulative_bound, years, tag): # from cumulative constraint scenario. # -------------------------------------------------------- - perbnd_scen = Scenario( - test_mp, MODEL, "period-bnd_many_tecs_" + tag, version="new" - ) + perbnd_scen = Scenario(test_mp, MODEL, "period-bnd_many_tecs_" + tag, version="new") model_setup(perbnd_scen, years, simple_tecs=False) for y in years: perbnd_scen.add_cat("year", y, y)