From 651b0179400f405b6cf29bf5e9bd244ffd9071de Mon Sep 17 00:00:00 2001 From: jernej-local Date: Fri, 10 Feb 2017 16:49:42 +0100 Subject: [PATCH] [FIX] Handle KeyError Sieve Diagram widget (owsieve.py) Issue KeyError thrown. Description Discretizer parameter remove_const set to False. Add test case. --- Orange/widgets/visualize/owsieve.py | 2 +- Orange/widgets/visualize/tests/test_owsieve.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/visualize/owsieve.py b/Orange/widgets/visualize/owsieve.py index 374b197b71f..cc0248ecaf0 100644 --- a/Orange/widgets/visualize/owsieve.py +++ b/Orange/widgets/visualize/owsieve.py @@ -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: diff --git a/Orange/widgets/visualize/tests/test_owsieve.py b/Orange/widgets/visualize/tests/test_owsieve.py index 9b644464cef..e3d49be86d1 100644 --- a/Orange/widgets/visualize/tests/test_owsieve.py +++ b/Orange/widgets/visualize/tests/test_owsieve.py @@ -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)