Skip to content

Commit

Permalink
manifold: Load openTSNE lazily
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Feb 15, 2020
1 parent aad5488 commit dbc8b30
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Orange/projection/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
from scipy.sparse.linalg import eigsh as arpack_eigh
import sklearn.manifold as skl_manifold

import openTSNE
import openTSNE.affinity
import openTSNE.initialization

import Orange
from Orange.data import Table, Domain, ContinuousVariable
from Orange.distance import Distance, DistanceModel, Euclidean
Expand All @@ -21,9 +17,18 @@
__all__ = ["MDS", "Isomap", "LocallyLinearEmbedding", "SpectralEmbedding",
"TSNE"]

# Disable t-SNE user warnings
openTSNE.tsne.log.setLevel(logging.ERROR)
openTSNE.affinity.log.setLevel(logging.ERROR)

class _LazyTSNE: # pragma: no cover
def __getattr__(self, attr):
global openTSNE
import openTSNE
# Disable t-SNE user warnings
openTSNE.tsne.log.setLevel(logging.ERROR)
openTSNE.affinity.log.setLevel(logging.ERROR)
return openTSNE.__dict__[attr]


openTSNE = _LazyTSNE()


def torgerson(distances, n_components=2, eigen_solver="auto"):
Expand Down

0 comments on commit dbc8b30

Please sign in to comment.