|
| 1 | +from typing import Literal |
| 2 | + |
1 | 3 | import pandas as pd
|
2 | 4 | import pytest
|
3 | 5 | from message_ix import Scenario
|
@@ -209,40 +211,29 @@ def test_non_cooling_tec(request, test_context):
|
209 | 211 |
|
210 | 212 | # Mock function for scen.par
|
211 | 213 | class MockScenario:
|
212 |
| - def par(self, param, filters): |
213 |
| - if param == "bound_activity_up": |
214 |
| - return pd.DataFrame( |
215 |
| - { |
216 |
| - "node_loc": ["R12_AFR", "R12_AFR", "R12_AFR"], |
217 |
| - "technology": ["coal_ppl", "coal_ppl", "coal_ppl"], |
218 |
| - "year_act": [2030, 2040, 2050], |
219 |
| - "value": [30, 15, 0], |
220 |
| - } |
221 |
| - ) |
222 |
| - elif param == "bound_new_capacity_up": |
223 |
| - return pd.DataFrame( |
224 |
| - { |
225 |
| - "node_loc": ["R12_AFR", "R12_AFR", "R12_AFR"], |
226 |
| - "technology": ["coal_ppl", "coal_ppl", "coal_ppl"], |
227 |
| - "year_vtg": [2030, 2040, 2050], |
228 |
| - "value": [30, 15, 0], |
229 |
| - } |
230 |
| - ) |
231 |
| - return pd.DataFrame() |
232 |
| - |
233 |
| - |
234 |
| -@pytest.mark.parametrize("constraint_type", ["activity", "new_capacity"]) |
235 |
| -def test_relax_growth_constraint(constraint_type): |
236 |
| - # Sample data for g_lo |
237 |
| - if constraint_type == "activity": |
238 |
| - year_type = "year_act" |
239 |
| - elif constraint_type == "new_capacity": |
240 |
| - year_type = "year_vtg" |
241 |
| - else: |
242 |
| - raise ValueError( |
243 |
| - "Invalid constraint_type. Must be 'activity' or 'new_capacity'." |
| 214 | + def par( |
| 215 | + self, |
| 216 | + param: Literal["bound_activity_up", "bound_new_capacity_up"], |
| 217 | + filters: dict, |
| 218 | + ) -> pd.DataFrame: |
| 219 | + year_type = "year_act" if param == "bound_activity_up" else "year_vtg" |
| 220 | + |
| 221 | + return pd.DataFrame( |
| 222 | + { |
| 223 | + "node_loc": ["R12_AFR", "R12_AFR", "R12_AFR"], |
| 224 | + "technology": ["coal_ppl", "coal_ppl", "coal_ppl"], |
| 225 | + year_type: [2030, 2040, 2050], |
| 226 | + "value": [30, 15, 0], |
| 227 | + } |
244 | 228 | )
|
245 | 229 |
|
| 230 | + |
| 231 | +@pytest.mark.parametrize( |
| 232 | + "constraint_type, year_type", |
| 233 | + [("activity", "year_act"), ("new_capacity", "year_vtg")], |
| 234 | +) |
| 235 | +def test_relax_growth_constraint(constraint_type, year_type): |
| 236 | + # Sample data for g_lo |
246 | 237 | g_lo = pd.DataFrame(
|
247 | 238 | {
|
248 | 239 | "node_loc": ["R12_AFR", "R12_AFR", "R12_AFR", "R12_AFR"],
|
|
0 commit comments