Skip to content

Commit 18af3c4

Browse files
adrivincamacflo8
authored andcommitted
Fix breaking test
1 parent ed3095c commit 18af3c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

message_ix_models/model/water/data/water_for_ppl.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ def relax_growth_constraint(
229229

230230
# In max_year_hist add the next year from years matching the hist_year columns
231231
max_year_hist["next_year"] = max_year_hist["hist_year"].apply(
232-
lambda x: years[years > x][0]
232+
lambda x: years[years > x][0] if any(years > x) else None
233233
)
234234

235235
# Merge the max_year_hist with bound_up_pare
236236
bound_up = pd.merge(bound_up_pare, max_year_hist, how="left")
237-
# Look at years just after the historical year
237+
# subset of first year after the historical
238+
# if next_year = None (single year test case) bound_up1 is simply empty
238239
bound_up1 = bound_up[bound_up[year_type] == bound_up["next_year"]]
239240
# Categories that might break the growth constraints
240241
bound_up1 = bound_up1[bound_up1["value"] < 0.9 * bound_up1["hist_value"]]

0 commit comments

Comments
 (0)