Skip to content

Commit

Permalink
Enhance test to check removal of 'is*' set is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
OFR-IIASA committed Nov 16, 2021
1 parent 0819879 commit d5c48b2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions message_ix/tests/test_emission_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,41 @@ def test_bound_emission_pool(test_mp):
obs = s.var("PRICE_EMISSION_POOL")

pdt.assert_frame_equal(exp, obs, check_dtype=False)


def test_bound_emission_pool_removal(test_mp):
s = make_westeros(test_mp, quiet=True)
prep_scenario(s, test_mp)

s.check_out()
df = pd.DataFrame(
{
"node": "Westeros",
"type_emission": "GHG",
"type_tec": "all",
"year": [700, 710, 720],
"value": [87000, 86000, 85000],
"unit": "???",
}
)
s.add_par("bound_emission_pool", df)
s.commit("bound_emission_pool added")

# Ensure that bound has been added
obs = s.par("bound_emission_pool")
pdt.assert_frame_equal(df, obs, check_dtype=False)

s.solve()

# Ensure that is_ set for bound has been added upon solving
exp = df.drop(["value", "unit"], axis=1)
obs = s.set("is_bound_emission_pool")
pdt.assert_frame_equal(exp, obs, check_dtype=False)

s.remove_solution()
s.check_out()
s.remove_par("bound_emission_pool", df)
s.commit("bound_emission_poll removed")

obs = s.set("is_bound_emission_pool")
assert obs.empty is True

0 comments on commit d5c48b2

Please sign in to comment.