Skip to content

Commit

Permalink
Merge pull request biolab#2007 from jerneju/keyerror-owsieve
Browse files Browse the repository at this point in the history
[FIX] Handle KeyError Sieve Diagram widget (owsieve) when one row
(cherry picked from commit b1fbf0a)
  • Loading branch information
astaric committed Feb 14, 2017
1 parent a54b9ce commit 06c7afa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owsieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def set_data(self, data):
self.domain_model.set_domain(data.domain)
if any(attr.is_continuous for attr in data.domain):
discretizer = Discretize(
method=EqualFreq(n=4),
method=EqualFreq(n=4),remove_const=False,
discretize_classes=True, discretize_metas=True)
self.discrete_data = discretizer(data)
else:
Expand Down
9 changes: 9 additions & 0 deletions Orange/widgets/visualize/tests/test_owsieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ def test_missing_values(self):
X = np.array([1, 2, 0, 1, 0, 2])[:, None]
data = Table(Domain(attrs, class_var), X, np.array([np.nan] * 6))
self.send_signal("Data", data)

def test_keyerror(self):
"""gh-2007
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)

0 comments on commit 06c7afa

Please sign in to comment.