From f7a7c697f8a0806c770bd490e171853bcc450255 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Wed, 25 Oct 2017 12:09:32 +0900 Subject: [PATCH] FIX: Remove 0.0 from `candidates` in `solve_discrete_riccati` (#364) * FIX: Remove 0.0 from `candidates` in `solve_discrete_riccati` Fix #356 * TEST: Set atol in `test_robust_rule_vs_simple` --- quantecon/matrix_eqn.py | 2 +- quantecon/tests/test_robustlq.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quantecon/matrix_eqn.py b/quantecon/matrix_eqn.py index 01dceaab5..c09de599a 100644 --- a/quantecon/matrix_eqn.py +++ b/quantecon/matrix_eqn.py @@ -160,7 +160,7 @@ def solve_discrete_riccati(A, B, Q, R, N=None, tolerance=1e-10, max_iter=500): # == Choose optimal value of gamma in R_hat = R + gamma B'B == # current_min = np.inf - candidates = (0.0, 0.01, 0.1, 0.25, 0.5, 1.0, 2.0, 10.0, 100.0, 10e5) + candidates = (0.01, 0.1, 0.25, 0.5, 1.0, 2.0, 10.0, 100.0, 10e5) BB = dot(B.T, B) BTA = dot(B.T, A) for gamma in candidates: diff --git a/quantecon/tests/test_robustlq.py b/quantecon/tests/test_robustlq.py index f9c386564..d4d29773c 100644 --- a/quantecon/tests/test_robustlq.py +++ b/quantecon/tests/test_robustlq.py @@ -78,9 +78,10 @@ def test_robust_rule_vs_simple(self): assert_allclose(Kr, Ks, rtol=1e-4) assert_allclose(Pr, Ps, rtol=1e-4) + atol = 1e-10 assert_allclose(Fr_pf, Fs_pf, rtol=1e-4) - assert_allclose(Kr_pf, Ks_pf, rtol=1e-4) - assert_allclose(Pr_pf, Ps_pf, rtol=1e-4) + assert_allclose(Kr_pf, Ks_pf, rtol=1e-4, atol=atol) + assert_allclose(Pr_pf, Ps_pf, rtol=1e-4, atol=atol) def test_f2k_and_k2f(self):