-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ConsRiskyAssetModel and fix simulation
Simulation didn't work for ConsRiskyAssetConsumerType because Share was never being set. Tests were missing so it was never caught before.
- Loading branch information
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
from HARK.tests import HARK_PRECISION | ||
from HARK.ConsumptionSaving.ConsRiskyAssetModel import IndShockRiskyAssetConsumerType | ||
|
||
|
||
class testRiskyAssetConsumerType(unittest.TestCase): | ||
def setUp(self): | ||
self.agent = IndShockRiskyAssetConsumerType() | ||
self.agent.vFuncBool = False | ||
self.agent.solve() | ||
|
||
def test_solution(self): | ||
cFunc = self.agent.solution[0].cFunc | ||
mNrm = 10.0 | ||
self.assertAlmostEqual(cFunc(mNrm).tolist(), 5.637216, places=HARK_PRECISION) | ||
|
||
# TODO: Turn this on after solver overhaul branch is merged | ||
# def test_value(self): | ||
# vFunc = self.agent.solution[0].vFunc | ||
# mNrm = 10.0 | ||
# self.assertAlmostEqual(vFunc(mNrm), -0.0000, places=HARK_PRECISION) | ||
|
||
def test_simulation(self): | ||
self.agent.T_sim = 10 | ||
self.agent.track_vars = ["mNrm", "cNrm", "aNrm"] | ||
self.agent.make_shock_history() | ||
self.agent.initialize_sim() | ||
self.agent.simulate() |