Skip to content

Commit dea98f8

Browse files
committed
owheatmap: Fix assertion error when restoring selection
... when input does not have enough columns for clustering.
1 parent 69fa799 commit dea98f8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Orange/widgets/visualize/owheatmap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ def is_variable(obj):
662662

663663
self.update_heatmaps()
664664
if data is not None and self.__pending_selection is not None:
665-
assert self.scene.widget is not None
666-
self.scene.widget.selectRows(self.__pending_selection)
665+
if self.scene.widget is not None:
666+
self.scene.widget.selectRows(self.__pending_selection)
667667
self.selected_rows = self.__pending_selection
668668
self.__pending_selection = None
669669

Orange/widgets/visualize/tests/test_owheatmap.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ def test_saved_selection(self):
205205
self.send_signal(w.Inputs.data, iris, widget=w)
206206
self.assertEqual(len(self.get_output(w.Outputs.selected_data)), 21)
207207

208+
def test_saved_selection_when_not_possible(self):
209+
# Has stored selection but ot enough columns for clustering.
210+
iris = Table("iris")[:, ["petal width"]]
211+
w = self.create_widget(
212+
OWHeatMap, stored_settings={
213+
"__version__": 3,
214+
"col_clustering_method": "Clustering",
215+
"selected_rows": [1, 2, 3],
216+
}
217+
)
218+
self.send_signal(w.Inputs.data, iris)
219+
out = self.get_output(w.Outputs.selected_data)
220+
self.assertSequenceEqual(list(out.ids), list(iris.ids[[1, 2, 3]]))
221+
208222
def test_set_split_var(self):
209223
data = self.brown_selected[::3]
210224
w = self.widget

0 commit comments

Comments
 (0)