From d3273f91203f202a7cc55bb01a4a8da4b193e39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavlin=20Poli=C4=8Dar?= Date: Mon, 25 Oct 2021 10:38:47 +0200 Subject: [PATCH] tsne: require opentsne 0.6.1 --- Orange/tests/test_manifold.py | 22 +++++++++++++++++++++- conda-recipe/meta.yaml | 2 +- requirements-core.txt | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Orange/tests/test_manifold.py b/Orange/tests/test_manifold.py index cf332ea22d6..803d5a42c6e 100644 --- a/Orange/tests/test_manifold.py +++ b/Orange/tests/test_manifold.py @@ -1,6 +1,7 @@ # Test methods with long descriptive names can omit docstrings # pylint: disable=missing-docstring - +import pickle +import platform import unittest import numpy as np @@ -245,3 +246,22 @@ def test_fft_correctness(self): knn.fit(model.embedding_, self.iris.Y) predicted = knn.predict(model.embedding_) self.assertTrue(accuracy_score(predicted, self.iris.Y) > 0.95) + + @unittest.skipIf(platform.system() == "Windows", "Files locked on Windows") + def test_pickle(self): + for neighbors in ("exact", "approx"): + tsne = TSNE(early_exaggeration_iter=0, n_iter=10, perplexity=30, + neighbors=neighbors, random_state=0) + model = tsne(self.iris[::2]) + + loaded_model = pickle.loads(pickle.dumps(model)) + + new_embedding = loaded_model(self.iris[1::2]).X + + knn = KNeighborsClassifier(n_neighbors=5) + knn.fit(new_embedding, self.iris[1::2].Y) + predicted = knn.predict(new_embedding) + self.assertTrue( + accuracy_score(predicted, self.iris[1::2].Y) > 0.95, + msg=f"Pickling failed with `neighbors={neighbors}`", + ) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index d63df79ffe5..006c7a872e1 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -56,7 +56,7 @@ requirements: - python-louvain >=0.13 - requests - matplotlib-base >=2.0.0 - - openTSNE >=0.6.0 + - openTSNE >=0.6.1 - pandas >=1.0.0 - pyyaml - orange-canvas-core >=0.1.21,<0.2a diff --git a/requirements-core.txt b/requirements-core.txt index 294fa277a82..882fd52484c 100644 --- a/requirements-core.txt +++ b/requirements-core.txt @@ -18,7 +18,7 @@ serverfiles # for Data Sets synchronization networkx python-louvain>=0.13 requests -openTSNE>=0.6.0 +openTSNE>=0.6.1 baycomp>=1.0.2 pandas>=1.0.0 pyyaml