Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monkey-patch scipy.linalg.triu for gensim #1060

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions orangecontrib/text/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
)
from Orange.preprocess.transformation import Identity
from Orange.data.util import get_unique_names

# Gensim is 4.3.2 is incompatible with scipy 1.3, where they removed triu/
# thus hack what it is missing here it.
# Remove this section after we depend on newer gensim
import scipy.linalg
if "triu" not in scipy.linalg.__dict__:
scipy.linalg.triu = np.triu

from gensim import corpora
from orangewidget.utils.signals import summarize, PartialSummary
import scipy.sparse as sp
Expand Down
12 changes: 12 additions & 0 deletions orangecontrib/text/tests/test_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
from orangecontrib.text.tag import AveragedPerceptronTagger


class ImportHack(unittest.TestCase):

def test_perhaps_remove_gensim_hack(self):
now = datetime.now()
if (now.year, now.month) >= (2024, 7):
self.fail(
"Check if gensim newer than 4.3.2 is available; if so, add it "
"to requirements, remove the scipy monkey-patch in corpus.py "
"and this test."
)


class CorpusTests(unittest.TestCase):
def setUp(self):
self.pos_tagger = AveragedPerceptronTagger()
Expand Down
Loading