From 21d3da1e3dc4bb66c51483a01382345e6eb59c0a Mon Sep 17 00:00:00 2001 From: rok Date: Fri, 10 Feb 2017 11:58:11 +0100 Subject: [PATCH] [FIX] OWMosaic: Fix crash for empty column --- Orange/widgets/visualize/owmosaic.py | 3 ++- Orange/widgets/visualize/tests/test_owmosaic.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/visualize/owmosaic.py b/Orange/widgets/visualize/owmosaic.py index 2f1b652c72e..633074a10ad 100644 --- a/Orange/widgets/visualize/owmosaic.py +++ b/Orange/widgets/visualize/owmosaic.py @@ -400,7 +400,8 @@ def set_data(self, data): self.closeContext() self.data = data self.init_combos(self.data) - if self.data is None or not len(self.data): + if self.data is None or not len(self.data) or not \ + any(attr.is_discrete or attr.is_continuous for attr in chain(data.domain, data.domain.metas)): self.discrete_data = None elif any(attr.is_continuous for attr in data.domain): self.discrete_data = Discretize( diff --git a/Orange/widgets/visualize/tests/test_owmosaic.py b/Orange/widgets/visualize/tests/test_owmosaic.py index d1e87b6af5a..4234d5da301 100644 --- a/Orange/widgets/visualize/tests/test_owmosaic.py +++ b/Orange/widgets/visualize/tests/test_owmosaic.py @@ -26,6 +26,10 @@ def test_no_data(self): """Check that the widget doesn't crash on empty data""" self.send_signal("Data", self.data[:0]) + def test_empty_column(self): + """Check that the widget doesn't crash if the columns are empty""" + self.send_signal("Data", self.data[:,:0]) + def _select_data(self): self.widget.select_area(1, QMouseEvent( QEvent.MouseButtonPress, QPoint(), Qt.LeftButton,