From 298a40bd9ed51f9ac26cd1d856691e09503b3551 Mon Sep 17 00:00:00 2001 From: Alejandro Ouslan Date: Sun, 8 Dec 2024 18:32:42 -0400 Subject: [PATCH] fixed #357 where methode is depricated --- pygam/pygam.py | 6 +++--- pygam/terms.py | 2 +- pygam/utils.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pygam/pygam.py b/pygam/pygam.py index bebcef13..a5c92293 100644 --- a/pygam/pygam.py +++ b/pygam/pygam.py @@ -703,7 +703,7 @@ def _initial_estimate(self, y, modelmat): # solve the linear problem return np.linalg.solve( - load_diagonal(modelmat.T.dot(modelmat).A), modelmat.T.dot(y_) + load_diagonal(modelmat.T.dot(modelmat).toarray()), modelmat.T.dot(y_) ) # not sure if this is faster... @@ -780,7 +780,7 @@ def _pirls(self, X, Y, weights): self._on_loop_start(vars()) WB = W.dot(modelmat[mask, :]) # common matrix product - Q, R = np.linalg.qr(WB.A) + Q, R = np.linalg.qr(WB.toarray()) if not np.isfinite(Q).all() or not np.isfinite(R).all(): raise ValueError( @@ -1401,7 +1401,7 @@ def _get_quantiles( idxs = self.terms.get_coef_indices(term) cov = self.statistics_['cov'][idxs][:, idxs] - var = (modelmat.dot(cov) * modelmat.A).sum(axis=1) + var = (modelmat.dot(cov) * modelmat.toarray()).sum(axis=1) if prediction: var += self.distribution.scale diff --git a/pygam/terms.py b/pygam/terms.py index c033e726..83fb22af 100644 --- a/pygam/terms.py +++ b/pygam/terms.py @@ -1500,7 +1500,7 @@ def _build_marginal_constraints(self, i, coef, constraint_lam, constraint_l2): ) # now enter it into the composite - composite_C[tuple(np.meshgrid(slice_, slice_))] = slice_C.A + composite_C[tuple(np.meshgrid(slice_, slice_))] = slice_C.toarray() return sp.sparse.csc_matrix(composite_C) diff --git a/pygam/utils.py b/pygam/utils.py index bc65ad5c..279989bc 100644 --- a/pygam/utils.py +++ b/pygam/utils.py @@ -64,7 +64,7 @@ def cholesky(A, sparse=True, verbose=True): # noqa: F811 if sparse: return L.T # upper triangular factorization - return L.T.A # upper triangular factorization + return L.T.toarray() # upper triangular factorization else: msg = ( @@ -78,7 +78,7 @@ def cholesky(A, sparse=True, verbose=True): # noqa: F811 warnings.warn(msg) if sp.sparse.issparse(A): - A = A.A + A = A.toarray() try: L = sp.linalg.cholesky(A, lower=False) @@ -951,10 +951,10 @@ def tensor_product(a, b, reshape=True): raise ValueError('both arguments must have the same number of samples') if sp.sparse.issparse(a): - a = a.A + a = a.toarray() if sp.sparse.issparse(b): - b = b.A + b = b.toarray() tensor = a[..., :, None] * b[..., None, :]