From 06c7afa6eeb87d09fa09b5d41a49dcbdaa3de11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Stari=C4=8D?= Date: Mon, 13 Feb 2017 14:05:41 +0100 Subject: [PATCH] Merge pull request #2007 from jerneju/keyerror-owsieve [FIX] Handle KeyError Sieve Diagram widget (owsieve) when one row (cherry picked from commit b1fbf0a17b69d712f3aaa2c6cf8052c3780d0df1) --- 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)