Skip to content

Commit 797b483

Browse files
OWFeatureStatistics: Fix crash when switching to data set with no target variable
1 parent f2ec533 commit 797b483

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Orange/widgets/data/owfeaturestatistics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ def set_data(self, data):
787787

788788
if data is not None:
789789
self.color_var_model.set_domain(data.domain)
790+
self.color_var = None
790791
if self.data.domain.class_vars:
791792
self.color_var = self.data.domain.class_vars[0]
792793
else:

Orange/widgets/data/tests/test_owfeaturestatistics.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,30 @@ def test_on_data_with_continuous_values_all_the_same(self, prepare_table):
251251
self.send_signal('Data', prepare_table(data))
252252
self.run_through_variables()
253253

254+
def test_switching_to_dataset_with_no_target_var(self):
255+
"""Switching from data set with target variable to a data set with
256+
no target variable should not result in crash."""
257+
data1 = make_table([continuous_full, ints_full], [ints_same, rgb_same])
258+
data2 = make_table([rgb_full, ints_full])
259+
260+
self.send_signal(self.widget.Inputs.data, data1)
261+
self.force_render_table()
262+
263+
self.send_signal(self.widget.Inputs.data, data2)
264+
self.force_render_table()
265+
266+
def test_switching_to_dataset_with_target_var(self):
267+
"""Switching from data set with no target variable to a data set with
268+
a target variable should not result in crash."""
269+
data1 = make_table([rgb_full, ints_full])
270+
data2 = make_table([continuous_full, ints_full], [ints_same, rgb_same])
271+
272+
self.send_signal(self.widget.Inputs.data, data1)
273+
self.force_render_table()
274+
275+
self.send_signal(self.widget.Inputs.data, data2)
276+
self.force_render_table()
277+
254278

255279
def select_rows(rows: List[int], widget: OWFeatureStatistics):
256280
"""Since the widget sorts the rows, selecting rows isn't trivial."""

0 commit comments

Comments
 (0)