Skip to content

Commit

Permalink
Heat map: Cannot cluster a single instance
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Aug 22, 2019
1 parent bf6edbe commit ba05484
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ def __new__(cls, title, indices, sortindices, cluster=None,
@property
def is_empty(self):
if isinstance(self.indices, slice):
return (self.indices.stop - self.indices.start) == 0
return (self.indices.stop - self.indices.start) < 2
else:
return len(self.indices) == 0
return len(self.indices) < 2

@property
def cluster_ord(self):
Expand Down
9 changes: 8 additions & 1 deletion Orange/widgets/visualize/tests/test_owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
from sklearn.exceptions import ConvergenceWarning

from Orange.data import Table, Domain, ContinuousVariable
from Orange.data import Table, Domain, ContinuousVariable, DiscreteVariable
from Orange.preprocess import Continuize
from Orange.widgets.visualize.owheatmap import OWHeatMap
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin, datasets
Expand Down Expand Up @@ -168,3 +168,10 @@ def test_use_enough_colors(self):
colors[r] = c.red(), c.green(), c.blue()
unique_colors = len(np.unique(colors, axis=0))
self.assertLessEqual(len(data)*self.widget.threshold_low, unique_colors)

def test_cls_with_single_instance(self):
table = Table(Domain([ContinuousVariable("c1")],
[DiscreteVariable("c2", values=["a", "b"])]),
np.array([[1], [2], [3]]), np.array([[0], [0], [1]]))
self.send_signal(self.widget.Inputs.data, table)
self.widget.row_check.setChecked(True)

0 comments on commit ba05484

Please sign in to comment.