Skip to content

Commit da01e9e

Browse files
authored
Merge pull request #2337 from jerneju/key-selectrows
[FIX] File: no domain or empty domain -> no data
2 parents 29fd47b + 8e8a51f commit da01e9e

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

Orange/widgets/data/owfile.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,18 @@ def retrieveSpecificSettings(self):
400400
self.variables[:] = self.current_context.modified_variables
401401

402402
def apply_domain_edit(self):
403-
if self.data is not None:
404-
domain, cols = self.domain_editor.get_domain(self.data.domain, self.data)
405-
X, y, m = cols
406-
table = Table.from_numpy(domain, X, y, m, self.data.W)
407-
table.name = self.data.name
408-
table.ids = np.array(self.data.ids)
409-
table.attributes = getattr(self.data, 'attributes', {})
403+
if self.data is None:
404+
table = None
410405
else:
411-
table = self.data
406+
domain, cols = self.domain_editor.get_domain(self.data.domain, self.data)
407+
if not (domain.variables or domain.metas):
408+
table = None
409+
else:
410+
X, y, m = cols
411+
table = Table.from_numpy(domain, X, y, m, self.data.W)
412+
table.name = self.data.name
413+
table.ids = np.array(self.data.ids)
414+
table.attributes = getattr(self.data, 'attributes', {})
412415

413416
self.send("Data", table)
414417
self.apply_button.setEnabled(False)

Orange/widgets/data/tests/test_owfile.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,19 @@ def test_domain_edit_on_sparse_data(self):
215215
self.assertIsInstance(output, Table)
216216
self.assertEqual(iris.X.shape, output.X.shape)
217217
self.assertTrue(sp.issparse(output.X))
218+
219+
def test_drop_data_when_everything_skipped(self):
220+
"""
221+
No data when everything is skipped. Otherwise Select Rows crashes.
222+
GH-2237
223+
"""
224+
self.open_dataset("iris")
225+
data = self.get_output("Data")
226+
self.assertTrue(len(data), 150)
227+
self.assertTrue(len(data.domain), 5)
228+
for i in range(5):
229+
idx = self.widget.domain_editor.model().createIndex(i, 2)
230+
self.widget.domain_editor.model().setData(idx, "skip", Qt.EditRole)
231+
self.widget.apply_button.click()
232+
data = self.get_output("Data")
233+
self.assertIsNone(data)

0 commit comments

Comments
 (0)