Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Orange/widgets/data/owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,18 @@ def retrieveSpecificSettings(self):
self.variables[:] = self.current_context.modified_variables

def apply_domain_edit(self):
if self.data is not None:
domain, cols = self.domain_editor.get_domain(self.data.domain, self.data)
X, y, m = cols
table = Table.from_numpy(domain, X, y, m, self.data.W)
table.name = self.data.name
table.ids = np.array(self.data.ids)
table.attributes = getattr(self.data, 'attributes', {})
if self.data is None:
table = None
else:
table = self.data
domain, cols = self.domain_editor.get_domain(self.data.domain, self.data)
if not (domain.variables or domain.metas):
table = None
else:
X, y, m = cols
table = Table.from_numpy(domain, X, y, m, self.data.W)
table.name = self.data.name
table.ids = np.array(self.data.ids)
table.attributes = getattr(self.data, 'attributes', {})

self.send("Data", table)
self.apply_button.setEnabled(False)
Expand Down
16 changes: 16 additions & 0 deletions Orange/widgets/data/tests/test_owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,19 @@ def test_domain_edit_on_sparse_data(self):
self.assertIsInstance(output, Table)
self.assertEqual(iris.X.shape, output.X.shape)
self.assertTrue(sp.issparse(output.X))

def test_drop_data_when_everything_skipped(self):
"""
No data when everything is skipped. Otherwise Select Rows crashes.
GH-2237
"""
self.open_dataset("iris")
data = self.get_output("Data")
self.assertTrue(len(data), 150)
self.assertTrue(len(data.domain), 5)
for i in range(5):
idx = self.widget.domain_editor.model().createIndex(i, 2)
self.widget.domain_editor.model().setData(idx, "skip", Qt.EditRole)
self.widget.apply_button.click()
data = self.get_output("Data")
self.assertIsNone(data)