Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Group by: Restore aggregations if removed due to open context #5823

Merged
merged 1 commit into from
Feb 4, 2022
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
5 changes: 5 additions & 0 deletions Orange/widgets/data/owgroupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,14 @@ def set_data(self, data: Table) -> None:
if data
else {}
)
default_aggregations = self.aggregations.copy()

self.openContext(self.data)

# restore aggregations
self.aggregations.update({k: v for k, v in default_aggregations.items()
if k not in self.aggregations})

# update selections in widgets and re-plot
self.agg_table_model.set_domain(data.domain if data else None)
self._set_gb_selection()
Expand Down
10 changes: 9 additions & 1 deletion Orange/widgets/data/tests/test_owgroupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from Orange.widgets.tests.base import WidgetTest


class TestOWGropBy(WidgetTest):
class TestOWGroupBy(WidgetTest):
def setUp(self) -> None:
self.widget = self.create_widget(OWGroupBy)
self.iris = Table("iris")
Expand All @@ -46,6 +46,14 @@ def test_data(self):
self.send_signal(self.widget.Inputs.data, None)
self.assertIsNone(self.get_output(self.widget.Outputs.data))

def test_data_domain_changed(self):
self.send_signal(self.widget.Inputs.data, self.iris[:, -2:])
self.assert_aggregations_equal(["Mean", "Concatenate"])

self.send_signal(self.widget.Inputs.data, self.iris[:, -3:])
self.assert_aggregations_equal(["Mean", "Mean", "Concatenate"])
self.select_table_rows(self.widget.agg_table_view, [0])

@staticmethod
def _set_selection(view: QListView, indices: List[int]):
view.clearSelection()
Expand Down