Skip to content

Commit

Permalink
added function to remove, but observe error
Browse files Browse the repository at this point in the history
  • Loading branch information
gidden committed Aug 9, 2019
1 parent 2236203 commit e48d56f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions message_ix/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,20 @@ def _aconst(self):
return self.data['aconst']


def remove(s):
for key in MACRO_INIT['sets']:
if key in s.set_list():
s.remove_set(key)
for key in MACRO_INIT['pars']:
if key in s.par_list():
s.remove_par(key)


def init(s):
for key, values in MACRO_INIT['sets'].items():
s.init_set(key, values)
for key, values in MACRO_INIT['pars'].items():
try:
s.init_par(key, values['idx'])
except: # noqa: ignore=E722
pass # already exists in the model, known for 'historical_gdp'
s.init_par(key, values['idx'])
for key, values in MACRO_INIT['vars'].items():
if not s.has_var(key):
try:
Expand Down
1 change: 1 addition & 0 deletions tests/test_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def test_init(test_mp):

scen = scen.clone('foo', 'bar')
scen.check_out()
macro.remove(scen)
macro.init(scen)
scen.commit('foo')
scen.solve()
Expand Down

0 comments on commit e48d56f

Please sign in to comment.