Skip to content

Commit 09ab550

Browse files
authored
Merge pull request #509 from duncanhobbs/fix-tests
[FIX] Fix Future Warnings in ivp.py and test_quad.py and RuntimeError in lq_control.py.
2 parents d9c1e8a + ae592db commit 09ab550

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

quantecon/ivp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def compute_residual(self, traj, ti, k=3, ext=2):
127127

128128
# rhs of ode evaluated along approximate solution
129129
T = ti.size
130-
rhs_ode = np.vstack(self.f(ti[i], soln[i, 1:], *self.f_params)
131-
for i in range(T))
130+
rhs_ode = np.vstack([self.f(ti[i], soln[i, 1:], *self.f_params)
131+
for i in range(T)])
132132
rhs_ode = np.hstack((ti[:, np.newaxis], rhs_ode))
133133

134134
# should be roughly zero everywhere (if approximation is any good!)

quantecon/lqcontrol.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ def __init__(self, Q, R, A, B, C=None, N=None, beta=1, T=None, Rf=None):
145145
self.d = None
146146
self.T = None
147147

148+
if (self.C != 0).any() and beta >= 1:
149+
raise ValueError('beta must be strictly smaller than 1 if ' +
150+
'T = None and C != 0.')
151+
148152
self.F = None
149153

150154
def __repr__(self):
@@ -241,7 +245,10 @@ def stationary_values(self, method='doubling'):
241245
F = solve(S1, S2)
242246

243247
# == Compute d == #
244-
d = self.beta * np.trace(dot(P, dot(C, C.T))) / (1 - self.beta)
248+
if self.beta == 1:
249+
d = 0
250+
else:
251+
d = self.beta * np.trace(dot(P, dot(C, C.T))) / (1 - self.beta)
245252

246253
# == Bind states and return values == #
247254
self.P, self.F, self.d = P, F, d

quantecon/tests/test_quad.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def setUpClass(cls):
115115
for kind in kinds:
116116
for num in n:
117117
num_in = num ** 2 if len(kind) == 1 else num
118-
quad_rect_res1d.ix[func_name, num][kind] = quadrect(func,
118+
quad_rect_res1d.loc[func_name, num][kind] = quadrect(func,
119119
num_in,
120120
a, b,
121121
kind)
@@ -136,10 +136,10 @@ def setUpClass(cls):
136136

137137
for num in n:
138138
for kind in kinds2[:4]:
139-
data2.ix[num**2][kind] = quadrect(f1_2, [num, num],
139+
data2.loc[num**2][kind] = quadrect(f1_2, [num, num],
140140
a[0], b[0], kind)
141141
for kind in kinds2[4:]:
142-
data2.ix[num**2][kind] = quadrect(f1_2, num**2, a[0],
142+
data2.loc[num**2][kind] = quadrect(f1_2, num**2, a[0],
143143
b[0], kind)
144144

145145
cls.data2d1 = data2
@@ -151,7 +151,7 @@ def setUpClass(cls):
151151

152152
for num in n3:
153153
for kind in kinds2[3:]:
154-
data3.ix[num][kind] = quadrect(f2_2, num, a[1], b[1], kind)
154+
data3.loc[num][kind] = quadrect(f2_2, num, a[1], b[1], kind)
155155

156156
cls.data2d2 = data3
157157

quantecon/tests/test_robustlq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def setUp(self):
4848
# (see p171 in Robustness)
4949
self.rblq_test = RBLQ(Q, R, A, B, C, beta, theta)
5050
self.rblq_test_pf = RBLQ(Q_pf, R, A, B_pf, C, beta, theta)
51-
self.lq_test = LQ(Q, R, A, B, C, beta)
51+
self.lq_test = LQ(Q, R, A, B, C, beta=beta)
5252
self.methods = ['doubling', 'qz']
5353

5454
def tearDown(self):

0 commit comments

Comments
 (0)