From b399d8742cfe9fc48ed219a57e4e84207f333af6 Mon Sep 17 00:00:00 2001 From: "Matthew N. White" Date: Tue, 10 Dec 2024 11:50:59 -0500 Subject: [PATCH] Add test for makeEulerErrorFunc --- .../tests/test_IndShockConsumerType.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py b/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py index 7f8e0a421..e2b274b70 100644 --- a/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py +++ b/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py @@ -215,11 +215,15 @@ def test_infinite_horizon(self): class testIndShockConsumerTypeExample(unittest.TestCase): - def test_infinite_horizon(self): + def setUp(self): IndShockExample = IndShockConsumerType(**IdiosyncDict) IndShockExample.assign_parameters( cycles=0 ) # Make this type have an infinite horizon + self.IndShockExample = IndShockExample + + def test_infinite_horizon(self): + IndShockExample = self.IndShockExample IndShockExample.solve() self.assertAlmostEqual( @@ -238,6 +242,14 @@ def test_infinite_horizon(self): # simulation test -- seed/generator specific # self.assertAlmostEqual( # IndShockExample.history["mNrm"][0][0], 1.01702, place = HARK_PRECISION # ) + def test_euler_error_function(self): + IndShockExample = self.IndShockExample + IndShockExample.solve() + IndShockExample.make_euler_error_func() + self.assertAlmostEqual( + IndShockExample.eulerErrorFunc(5.0), -5.9e-5, places=HARK_PRECISION + ) + LifecycleDict = { # Click arrow to expand this fairly large parameter dictionary # Parameters shared with the perfect foresight model