From fe730c252d4baf5395f2e63bd6b12c2969914483 Mon Sep 17 00:00:00 2001 From: Helge Hecht Date: Thu, 7 Nov 2024 10:49:11 +0100 Subject: [PATCH] removed scipy sparsetools functions --- gensim/models/lsimodel.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gensim/models/lsimodel.py b/gensim/models/lsimodel.py index cce19b0b6b..b6fb4bf125 100644 --- a/gensim/models/lsimodel.py +++ b/gensim/models/lsimodel.py @@ -66,7 +66,6 @@ import numpy as np import scipy.linalg import scipy.sparse -from scipy.sparse import sparsetools from gensim import interfaces, matutils, utils from gensim.models import basemodel @@ -960,10 +959,8 @@ def stochastic_svd( m, n = corpus.shape assert num_terms == m, f"mismatch in number of features: {m} in sparse matrix vs. {num_terms} parameter" o = random_state.normal(0.0, 1.0, (n, samples)).astype(y.dtype) # draw a random gaussian matrix - sparsetools.csc_matvecs( - m, n, samples, corpus.indptr, corpus.indices, - corpus.data, o.ravel(), y.ravel(), - ) # y = corpus * o + y = corpus.dot(o) # y = corpus * o + del o # unlike np, scipy.sparse `astype()` copies everything, even if there is no change to dtype! @@ -994,10 +991,7 @@ def stochastic_svd( num_docs += n logger.debug("multiplying chunk * gauss") o = random_state.normal(0.0, 1.0, (n, samples), ).astype(dtype) # draw a random gaussian matrix - sparsetools.csc_matvecs( - m, n, samples, chunk.indptr, chunk.indices, # y = y + chunk * o - chunk.data, o.ravel(), y.ravel(), - ) + y = y + chunk * o del chunk, o y = [y] q, _ = matutils.qr_destroy(y) # orthonormalize the range