Skip to content

Commit b85037a

Browse files
Copilotmmcky
andcommitted
Revert test files to original state - separate library changes from test updates
Per feedback, this keeps only the library code changes with @ operator migrations and reverts all test files to their original state. All 536 tests pass with the library changes, confirming compatibility. Test file updates can be done in a separate PR later. Co-authored-by: mmcky <[email protected]>
1 parent bdc7b5b commit b85037a

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

quantecon/markov/tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ def test_left_eigen_vec(self):
225225
stationary_distributions = self.stationary
226226

227227
if self.n_stat_dists == 1:
228-
assert_allclose(stationary_distributions @ mc.P,
228+
assert_allclose(np.dot(stationary_distributions, mc.P),
229229
stationary_distributions, atol=self.TOL)
230230
else:
231231
for i in range(self.n_stat_dists):
232232
curr_v = stationary_distributions[i, :]
233-
assert_allclose(curr_v @ mc.P, curr_v, atol=self.TOL)
233+
assert_allclose(np.dot(curr_v, mc.P), curr_v, atol=self.TOL)
234234

235235

236236
def test_simulate_shape():

quantecon/markov/tests/test_gth_solve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __call__(self, x):
108108

109109
class StationaryDistLeftEigenVec(AddDescription):
110110
def __call__(self, A, x):
111-
assert_allclose(x @ A, x, atol=TOL)
111+
assert_allclose(np.dot(x, A), x, atol=TOL)
112112

113113

114114
class StationaryDistEqualToKnown(AddDescription):

quantecon/tests/test_kalman.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def setup_method(self):
1717
self.G = np.eye(2) * .5
1818
self.H = np.eye(2) * np.sqrt(0.2)
1919

20-
self.Q = self.C @ self.C.T
21-
self.R = self.H @ self.H.T
20+
self.Q = np.dot(self.C, self.C.T)
21+
self.R = np.dot(self.H, self.H.T)
2222

2323
ss = LinearStateSpace(self.A, self.C, self.G, self.H)
2424

@@ -38,13 +38,13 @@ def test_stationarity(self):
3838
for method in self.methods:
3939
sig_inf, kal_gain = kf.stationary_values(method=method)
4040

41-
mat_inv = np.linalg.inv(G @ sig_inf @ G.T + R)
41+
mat_inv = np.linalg.inv(G.dot(sig_inf).dot(G.T) + R)
4242

4343
# Compute the kalmain gain and sigma infinity according to the
4444
# recursive equations and compare
45-
kal_recursion = (A @ sig_inf) @ G.T @ mat_inv
46-
sig_recursion = (A @ sig_inf @ A.T -
47-
kal_recursion @ G @ sig_inf @ A.T + Q)
45+
kal_recursion = np.dot(A, sig_inf).dot(G.T).dot(mat_inv)
46+
sig_recursion = (A.dot(sig_inf).dot(A.T) -
47+
kal_recursion.dot(G).dot(sig_inf).dot(A.T) + Q)
4848

4949
assert_allclose(kal_gain, kal_recursion, rtol=1e-4, atol=1e-2)
5050
assert_allclose(sig_inf, sig_recursion, rtol=1e-4, atol=1e-2)
@@ -75,12 +75,12 @@ def test_update_nonstationary(self):
7575
kf.set_state(curr_x, curr_sigma)
7676
kf.update(y_observed)
7777

78-
mat_inv = np.linalg.inv(G @ curr_sigma @ G.T + R)
79-
curr_k = (A @ curr_sigma) @ G.T @ mat_inv
80-
new_sigma = (A @ curr_sigma @ A.T -
81-
curr_k @ G @ curr_sigma @ A.T + Q)
78+
mat_inv = np.linalg.inv(G.dot(curr_sigma).dot(G.T) + R)
79+
curr_k = np.dot(A, curr_sigma).dot(G.T).dot(mat_inv)
80+
new_sigma = (A.dot(curr_sigma).dot(A.T) -
81+
curr_k.dot(G).dot(curr_sigma).dot(A.T) + Q)
8282

83-
new_xhat = A @ curr_x + curr_k @ (y_observed - G @ curr_x)
83+
new_xhat = A.dot(curr_x) + curr_k.dot(y_observed - G.dot(curr_x))
8484

8585
assert_allclose(kf.Sigma, new_sigma, rtol=1e-4, atol=1e-2)
8686
assert_allclose(kf.x_hat, new_xhat, rtol=1e-4, atol=1e-2)

quantecon/tests/test_lqcontrol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_stationary_mat(self):
8383

8484
for method in self.methods:
8585
P, F, d = lq_mat.stationary_values(method=method)
86-
val_func_lq = x0 @ P @ x0
86+
val_func_lq = np.dot(x0, P).dot(x0)
8787

8888
assert_allclose(f_answer, F, atol=1e-3)
8989
assert_allclose(val_func_lq, val_func_answer, atol=1e-3)

quantecon/tests/test_lqnash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def test_nnash(self):
8686
f1, f2, p1, p2 = nnash(a, b1, b2, r1, r2, q1, q2, s1, s2, w1, w2, m1,
8787
m2)
8888

89-
aaa = a - b1 @ f1 - b2 @ f2
89+
aaa = a - b1.dot(f1) - b2.dot(f2)
9090
aa = aaa[:2, :2]
9191
tf = np.eye(2)-aa
9292
tfi = np.linalg.inv(tf)
93-
xbar = tfi @ aaa[:2, 2]
93+
xbar = tfi.dot(aaa[:2, 2])
9494

9595
# Define answers from matlab. TODO: this is ghetto
9696
f1_ml = np.array([

quantecon/tests/test_matrix_eqn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ def test_solve_discrete_lyapunov_complex():
3434

3535
X = qme.solve_discrete_lyapunov(A, B)
3636

37-
assert_allclose((A @ X @ A.conj().transpose()) - X, -B,
37+
assert_allclose(np.dot(np.dot(A, X), A.conj().transpose()) - X, -B,
3838
atol=1e-15)

quantecon/tests/test_ricatti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def dare_tjm_3(method):
6262
B = I
6363
R = [[1, r],
6464
[r, r*r]]
65-
Q = I - (A.T @ A) + (A.T @ np.linalg.solve(R + I, A))
65+
Q = I - np.dot(A.T, A) + np.dot(A.T, np.linalg.solve(R + I, A))
6666
X = solve_discrete_riccati(A, B, Q, R, method=method)
6767
Y = np.identity(2)
6868
assert_allclose(X, Y, atol=1e-07)

0 commit comments

Comments
 (0)