From 1af9b1ff24828adf85a9bd91726911680b5bac78 Mon Sep 17 00:00:00 2001 From: Pedro Amaral Date: Wed, 13 Sep 2023 17:34:39 -0300 Subject: [PATCH] Attempt at fixing the SUR-related failures due to deprecation --- spreg/diagnostics_sur.py | 2 +- spreg/sur_utils.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/spreg/diagnostics_sur.py b/spreg/diagnostics_sur.py index 8e145b54..7fdfdb1d 100644 --- a/spreg/diagnostics_sur.py +++ b/spreg/diagnostics_sur.py @@ -221,7 +221,7 @@ def surLMlag(n_eq, WS, bigy, bigX, bigE, bigYP, sig, varb): """ # Score - Y = np.hstack((bigy[r]) for r in range(n_eq)) + Y = np.hstack([bigy[r] for r in range(n_eq)]) WY = WS * Y EWY = np.dot(bigE.T, WY) sigi = la.inv(sig) diff --git a/spreg/sur_utils.py b/spreg/sur_utils.py index 50dc7341..bb78d3c8 100644 --- a/spreg/sur_utils.py +++ b/spreg/sur_utils.py @@ -290,7 +290,9 @@ def sur_dict2mat(dicts): """ n_dicts = len(dicts.keys()) - mat = np.vstack((dicts[t] for t in range(n_dicts))) + #mat = np.vstack((dicts[t] for t in range(n_dicts))) + mat = np.vstack([dicts[t] for t in range(n_dicts)]) + return mat @@ -392,10 +394,11 @@ def sur_est(bigXX, bigXy, bigE, bigK): for t in range(n_eq): sxy = sxy + sigi[r, t] * bigXy[(r, t)] sigiXy[r] = sxy - xsigy = np.vstack((sigiXy[t] for t in range(n_eq))) - xsigx = np.vstack( - ((np.hstack(sigiXX[(r, t)] for t in range(n_eq))) for r in range(n_eq)) - ) + #xsigy = np.vstack((sigiXy[t] for t in range(n_eq))) + xsigy = np.vstack(tuple(sigiXy[t] for t in range(n_eq))) + #xsigx = np.vstack(((np.hstack(sigiXX[(r, t)] for t in range(n_eq))) for r in range(n_eq))) + array_lists = [[sigiXX[(r, t)] for t in range(n_eq)] for r in range(n_eq)] + xsigx = np.vstack([np.hstack(arr_list) for arr_list in array_lists]) varb = la.inv(xsigx) beta = np.dot(varb, xsigy) bSUR = sur_mat2dict(beta, bigK) @@ -423,7 +426,9 @@ def sur_resids(bigy, bigX, beta): """ n_eq = len(bigy.keys()) - bigE = np.hstack((bigy[r] - spdot(bigX[r], beta[r])) for r in range(n_eq)) + #bigE = np.hstack((bigy[r] - spdot(bigX[r], beta[r])) for r in range(n_eq)) + bigE = np.hstack(tuple(bigy[r] - spdot(bigX[r], beta[r]) for r in range(n_eq))) + return bigE @@ -449,7 +454,9 @@ def sur_predict(bigy, bigX, beta): """ n_eq = len(bigy.keys()) - bigYP = np.hstack(spdot(bigX[r], beta[r]) for r in range(n_eq)) + #bigYP = np.hstack(spdot(bigX[r], beta[r]) for r in range(n_eq)) + bigYP = np.hstack([spdot(bigX[r], beta[r]) for r in range(n_eq)]) + return bigYP