diff --git a/Orange/widgets/visualize/owheatmap.py b/Orange/widgets/visualize/owheatmap.py index 2f40d2cdf93..c31af945230 100644 --- a/Orange/widgets/visualize/owheatmap.py +++ b/Orange/widgets/visualize/owheatmap.py @@ -318,11 +318,11 @@ def __new__(cls, title, indices, sortindices, cluster=None, cluster, cluster_ordered) @property - def is_empty(self): + def can_cluster(self): if isinstance(self.indices, slice): - return (self.indices.stop - self.indices.start) == 0 + return (self.indices.stop - self.indices.start) > 1 else: - return len(self.indices) == 0 + return len(self.indices) > 1 @property def cluster_ord(self): @@ -794,7 +794,7 @@ def cluster_rows(self, data, parts): else: cluster_ord = None - if not row.is_empty: + if row.can_cluster: need_dist = cluster is None or cluster_ord is None if need_dist: subset = data[row.indices] diff --git a/Orange/widgets/visualize/tests/test_owheatmap.py b/Orange/widgets/visualize/tests/test_owheatmap.py index ea549d661a5..340b6ee9ed4 100644 --- a/Orange/widgets/visualize/tests/test_owheatmap.py +++ b/Orange/widgets/visualize/tests/test_owheatmap.py @@ -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 @@ -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)