Skip to content

Commit 823213f

Browse files
committed
Merge pull request biolab#2014 from jerneju/keyerror-mosaic
[FIX] Handle KeyError Mosaic Display (owmosaic.py) (cherry picked from commit 682a939)
1 parent 14135f2 commit 823213f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Orange/widgets/visualize/owmosaic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def set_data(self, data):
404404
self.discrete_data = None
405405
elif any(attr.is_continuous for attr in data.domain):
406406
self.discrete_data = Discretize(
407-
method=EqualFreq(n=4), discretize_classes=True,
407+
method=EqualFreq(n=4), remove_const=False, discretize_classes=True,
408408
discretize_metas=True)(data)
409409
else:
410410
self.discrete_data = self.data

Orange/widgets/visualize/tests/test_owmosaic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def test_missing_values(self):
5353
data = Table(Domain(attrs, class_var), X, np.array([np.nan] * 6))
5454
self.send_signal("Data", data)
5555

56+
def test_keyerror(self):
57+
"""gh-2014
58+
Check if it works when a table has only one row or duplicates.
59+
Discretizer must have remove_const set to False.
60+
"""
61+
data = Table("iris")
62+
data = data[0:1]
63+
self.send_signal("Data", data)
5664

5765
# Derive from WidgetTest to simplify creation of the Mosaic widget, although
5866
# we are actually testing the MosaicVizRank dialog and not the widget

0 commit comments

Comments
 (0)