Skip to content
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
3 changes: 3 additions & 0 deletions Orange/widgets/unsupervised/owmanifoldlearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class Error(OWWidget.Error):
sparse_methods = Msg('Only t-SNE method supported on sparse data')
sparse_tsne_distance = Msg('Chebyshev, Jaccard, and Mahalanobis '
'distances not supported with sparse data.')
out_of_memory = Msg("Out of memory")

def __init__(self):
self.data = None
Expand Down Expand Up @@ -271,6 +272,8 @@ def apply(self):
self.Error.n_neighbors_too_small("{}".format(n))
else:
self.Error.manifold_error(e.args[0])
except MemoryError:
self.Error.out_of_memory()
except np.linalg.linalg.LinAlgError as e:
self.Error.manifold_error(str(e))
self.Outputs.transformed_data.send(out)
Expand Down
15 changes: 15 additions & 0 deletions Orange/widgets/unsupervised/tests/test_owmanifoldlearning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring
from unittest.mock import patch, Mock

import numpy as np
from scipy import sparse

Expand Down Expand Up @@ -108,3 +110,16 @@ def test_singular_matrices(self):
self.assertFalse(self.widget.Error.manifold_error.is_shown())
self.widget.apply_button.button.click()
self.assertTrue(self.widget.Error.manifold_error.is_shown())

def test_out_of_memory(self):
"""
Show error message when out of memory.
GH-2441
"""
table = Table("iris")
with patch("Orange.projection.manifold.MDS.__call__", Mock()) as mock:
mock.side_effect = MemoryError
self.send_signal("Data", table)
self.widget.manifold_methods_combo.activated.emit(1)
self.widget.apply_button.button.click()
self.assertTrue(self.widget.Error.out_of_memory.is_shown())