Skip to content

Commit

Permalink
Merge pull request biolab#2014 from jerneju/keyerror-mosaic
Browse files Browse the repository at this point in the history
[FIX] Handle KeyError Mosaic Display (owmosaic.py)
  • Loading branch information
astaric authored Feb 14, 2017
2 parents ed3dcf6 + a254bf1 commit 682a939
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owmosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def set_data(self, data):
self.discrete_data = None
elif any(attr.is_continuous for attr in data.domain):
self.discrete_data = Discretize(
method=EqualFreq(n=4), discretize_classes=True,
method=EqualFreq(n=4), remove_const=False, discretize_classes=True,
discretize_metas=True)(data)
else:
self.discrete_data = self.data
Expand Down
8 changes: 8 additions & 0 deletions Orange/widgets/visualize/tests/test_owmosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def test_missing_values(self):
data = Table(Domain(attrs, class_var), X, np.array([np.nan] * 6))
self.send_signal("Data", data)

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

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

0 comments on commit 682a939

Please sign in to comment.