Skip to content

Commit

Permalink
Added test for additional projection data in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
gidden committed Aug 30, 2017
1 parent 34f188d commit d7d583f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,45 @@ def test_Model1_diffusion_result():


def test_runner_horizon():
# test on actual data
natdata, subdata = data()
runner = Runner(natdata, subdata, Model)
assert [(2010, 2020)] == list(runner.horizon())

# test of extended fake data
df = pd.DataFrame({'a': range(3)}, index=[2010, 2020, 2030])
runner = Runner(df, subdata, Model)
assert [(2010, 2020), (2020, 2030)] == list(runner.horizon())


def test_runner_data():
# test on actual data
natdata, subdata = data()
runner = Runner(natdata, subdata, Model)
obs_n, obs_s = runner._data(2010, 2020)
assert_frame_equal(obs_n, natdata)
assert_frame_equal(obs_s, subdata.sort_index())

# test of extended fake data
df1 = pd.DataFrame({'a': range(3)},
index=pd.Index([2010, 2020, 2030], name='year'))
idx = pd.MultiIndex.from_product([[2010, 2020, 2030], ['foo', 'bar']],
names=['year', 'name'])
df2 = pd.DataFrame({'a': range(3, 9)}, index=idx)
runner = Runner(df1, df2, Model)
# 2010-2020
obs_1, obs_2 = runner._data(2010, 2020)
exp = df1.loc[2010:2020]
assert_frame_equal(obs_1, exp)
exp = df2.loc[2010:2020].sort_index()
assert_frame_equal(obs_2, exp)
# 2020-2030
obs_1, obs_2 = runner._data(2020, 2030)
exp = df1.loc[2020:2030]
assert_frame_equal(obs_1, exp)
exp = df2.loc[2020:2030].sort_index()
assert_frame_equal(obs_2, exp)


def test_runner_update():
natdata, subdata = data()
Expand Down

0 comments on commit d7d583f

Please sign in to comment.