Skip to content

Commit

Permalink
updates to tests based on @Mv77's review. econ-ark#1105
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Sep 27, 2022
1 parent 3371efd commit e822f2f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions HARK/ConsumptionSaving/tests/test_ConsAggShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,16 @@ def test_methods(self):

# testing update_solution_terminal()
self.assertEqual(
self.agent.solution_terminal.cFunc[0](10, 13.32722),
self.agent.solution_terminal.cFunc[0](10, self.economy.MSS),
10
)

self.assertAlmostEqual(
self.economy.agents[0].solution[0].cFunc[0](
10, 13.32722
10, self.economy.MSS
).tolist(),
1.2386774
1.2386774,
places = 4
)

self.assertAlmostEqual(
Expand Down
2 changes: 1 addition & 1 deletion HARK/ConsumptionSaving/tests/test_ConsPortfolioModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_sim_one_period(self):
)

# a drawn shock ; may not be robust to RNG/disitrubition implementations
self.assertAlmostEqual(self.pcct.shocks["Adjust"][0], 1.0)
#self.assertAlmostEqual(self.pcct.shocks["Adjust"][0], 1.0)


class SimulatePortfolioConsumerTypeTestCase(PortfolioConsumerTypeTestCase):
Expand Down
9 changes: 5 additions & 4 deletions HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def test_simulated_values(self):
self.agent.initialize_sim()
self.agent.simulate()

self.assertAlmostEqual(self.agent.MPCnow[1], 0.5711503906043797)
# MPCnow depends on assets, which are stochastic
#self.assertAlmostEqual(self.agent.MPCnow[1], 0.5711503906043797)

# simulation test -- seed/generator specific
#self.assertAlmostEqual(self.agent.state_now["aLvl"][1], 0.18438326264597635)
Expand Down Expand Up @@ -704,9 +705,9 @@ def test_Harmenberg_mtd(self):
# simulation tests -- seed/generator specific
# But these are based on aggregate population statistics.
# WARNING: May fail stochastically, or based on specific RNG types.
self.assertAlmostEqual(c_std2, 0.0376882)
self.assertAlmostEqual(c_std1, 0.0044117)
self.assertAlmostEqual(c_std_ratio, 8.5426941)
#self.assertAlmostEqual(c_std2, 0.0376882, places = 2)
#self.assertAlmostEqual(c_std1, 0.0044117, places = 2)
#self.assertAlmostEqual(c_std_ratio, 8.5426941, places = 2)


# %% Shock pre-computing tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def test_ConsIndShockSolverBasic(self):
def test_simulated_values(self):
self.agent.initialize_sim()
self.agent.simulate()
self.assertAlmostEqual(self.agent.MPCnow[1], 0.5711503906043797)

#MPCnow is stochastic
#self.assertAlmostEqual(self.agent.MPCnow[1], 0.5711503906043797)

# simulation test -- seed/generator specific
# self.assertAlmostEqual(self.agent.state_now['aLvl'][1], 0.18438326264597635)
Expand Down
12 changes: 6 additions & 6 deletions HARK/tests/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,16 @@ def test_MVNormal(self):
## Are these tests generator/backend specific?
dist = MVNormal()

self.assertTrue(
np.allclose(dist.draw(1)[0], np.array([2.76405235, 1.40015721]))
)
#self.assertTrue(
# np.allclose(dist.draw(1)[0], np.array([2.76405235, 1.40015721]))
#)

dist.draw(100)
dist.reset()

self.assertTrue(
np.allclose(dist.draw(1)[0], np.array([2.76405235, 1.40015721]))
)
#self.assertTrue(
# np.allclose(dist.draw(1)[0], np.array([2.76405235, 1.40015721]))
#)

def test_Weibull(self):
Weibull().draw(1)[0]
Expand Down

0 comments on commit e822f2f

Please sign in to comment.