Skip to content

Commit

Permalink
OWTable: fix select whole rows regression
Browse files Browse the repository at this point in the history
And add a test for the feature.
  • Loading branch information
markotoplak committed Sep 23, 2021
1 parent c7e80de commit c4c4775
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Orange/widgets/data/owtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def _update_variable_labels(self, view):

def _on_show_variable_labels_changed(self):
"""The variable labels (var.attribues) visibility was changed."""
for slot in self._inputs.values():
for slot in self._inputs:
self._update_variable_labels(slot.view)

def _on_distribution_color_changed(self):
Expand All @@ -619,7 +619,7 @@ def _on_distribution_color_changed(self):
tab.reset()

def _on_select_rows_changed(self):
for slot in self._inputs.values():
for slot in self._inputs:
selection_model = slot.view.selectionModel()
selection_model.setSelectBlocks(not self.select_rows)
if self.select_rows:
Expand Down
30 changes: 29 additions & 1 deletion Orange/widgets/data/tests/test_owtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_reset_select(self):

def _select_data(self):
self.widget.selected_cols = list(range(len(self.data.domain.variables)))
self.widget.selected_rows = list(range(0, len(self.data.domain.variables), 10))
self.widget.selected_rows = list(range(0, len(self.data), 10))
self.widget.set_selection()
return self.widget.selected_rows

Expand Down Expand Up @@ -168,6 +168,34 @@ def test_show_distributions(self):
w.grab()
w.controls.show_distributions.toggle()

def test_whole_rows(self):
w = self.widget
self.send_signal(w.Inputs.data, self.data, 0)
self.assertTrue(w.select_rows) # default value
with excepthook_catch():
w.controls.select_rows.toggle()
self.assertFalse(w.select_rows)
w.selected_cols = [0, 1]
w.selected_rows = [0, 1, 2, 3]
w.set_selection()
out = self.get_output(w.Outputs.selected_data)
self.assertEqual(out.domain,
Domain([self.data.domain.attributes[0]], self.data.domain.class_var))
with excepthook_catch():
w.controls.select_rows.toggle()
out = self.get_output(w.Outputs.selected_data)
self.assertTrue(w.select_rows)
self.assertEqual(out.domain,
self.data.domain)

def test_show_attribute_labels(self):
w = self.widget
self.send_signal(w.Inputs.data, self.data, 0)
self.assertTrue(w.show_attribute_labels) # default value
with excepthook_catch():
w.controls.show_attribute_labels.toggle()
self.assertFalse(w.show_attribute_labels)


if __name__ == "__main__":
unittest.main()

0 comments on commit c4c4775

Please sign in to comment.