You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's wrong?
If first a subset of a table is given to group by (here: only sepal length with Select Columns), and then the remaining variables are added, the aggregations column in the aggregate table is empty. When clicking on the row, a KeyError exception occurs.
----------------------------- KeyError Exception ------------------------------
Traceback (most recent call last):
File "D:\dev\Python\orange3\orange3\Orange\widgets\data\owgroupby.py", line 385, in __rows_selected
active_aggregations = [self.aggregations[attr] for attr in selected_attrs]
File "D:\dev\Python\orange3\orange3\Orange\widgets\data\owgroupby.py", line 385, in <listcomp>
active_aggregations = [self.aggregations[attr] for attr in selected_attrs]
KeyError: ContinuousVariable(name='sepal width', number_of_decimals=1)
-------------------------------------------------------------------------------
How can we reproduce the problem?
see Screenshot
insert this test in TestOWGropBy in Orange/widgets/data/tests/test_owgroupby.py
def test_reproduce_bug(self):
partial_domain = Domain([ContinuousVariable("a")])
partial_table = Table.from_table(partial_domain, self.data)
self.send_signal(self.widget.Inputs.data, partial_table)
assert len(self.widget.aggregations) == 1
self.assert_aggregations_equal(["Mean"])
self.send_signal(self.widget.Inputs.data, self.data)
assert len(self.widget.aggregations) == 1 # should be 5
self.assert_aggregations_equal(['Mean', '', '', '', '']) # should be defaults, not ''
# select a new variable - should not raise
self.select_table_rows(self.widget.agg_table_view, [1])
Analysis and related problem
A ContextSetting is created with the partial table.
With the full table, this context is recognized and the default values of the new variables in self.aggregations (owgroupby) are completely overwritten with the ContextSetting of the partial table.
In self.agg_table_view are all variables, but in self.aggregations only one. KeyError.
If a ContextSetting is a dict, it completely replaces the current setting:
janezd
added
bug
A bug confirmed by the core team
and removed
bug report
Bug is reported by user, not yet confirmed by the core team
labels
Feb 3, 2022
Thanks for this excellent report. How I wish all reports were so detailed, and also included some debugging and even a test! :)
You are right, of course.
A note to whomever who'd work on this: this shouldn't be too difficult. Copy the idea from widgets that already do it properly, for instance, Discretize and Edit Domain. The latter is better, because it stores changes immediately, not through storeSpecificSettings.
What's wrong?
If first a subset of a table is given to group by (here: only sepal length with Select Columns), and then the remaining variables are added, the aggregations column in the aggregate table is empty. When clicking on the row, a KeyError exception occurs.
How can we reproduce the problem?
Analysis and related problem
A ContextSetting is created with the partial table.
With the full table, this context is recognized and the default values of the new variables in self.aggregations (owgroupby) are completely overwritten with the ContextSetting of the partial table.
In self.agg_table_view are all variables, but in self.aggregations only one. KeyError.
If a ContextSetting is a dict, it completely replaces the current setting:
https://github.com/biolab/orange-widget-base/blob/51d4f35e2fe807d617aac0547532d220d8942679/orangewidget/settings.py#L201
Wouldn't it be better if:
What's your environment?
The text was updated successfully, but these errors were encountered: