diff --git a/Orange/widgets/data/owpreprocess.py b/Orange/widgets/data/owpreprocess.py index bf776df702b..238be791e08 100644 --- a/Orange/widgets/data/owpreprocess.py +++ b/Orange/widgets/data/owpreprocess.py @@ -1144,6 +1144,9 @@ def mimeData(indexlist): box = gui.vBox(self.controlArea, "Output") gui.auto_send(box, self, "autocommit", box=False) + self.info.set_input_summary(self.info.NoInput) + self.info.set_output_summary(self.info.NoOutput) + self._initialize() def _initialize(self): @@ -1261,6 +1264,10 @@ def __on_modelchanged(self): def set_data(self, data=None): """Set the input dataset.""" self.data = data + if data is not None: + self.info.set_input_summary(len(data)) + else: + self.info.set_input_summary(self.info.NoInput) def handleNewSignals(self): self.apply() @@ -1304,8 +1311,10 @@ def apply(self): except (ValueError, ZeroDivisionError) as e: self.error(str(e)) return + self.info.set_output_summary(len(data)) else: data = None + self.info.set_output_summary(self.info.NoOutput) self.Outputs.preprocessor.send(preprocessor) self.Outputs.preprocessed_data.send(data) diff --git a/Orange/widgets/data/tests/test_owpreprocess.py b/Orange/widgets/data/tests/test_owpreprocess.py index 61a3a6e2fd0..873403cf4df 100644 --- a/Orange/widgets/data/tests/test_owpreprocess.py +++ b/Orange/widgets/data/tests/test_owpreprocess.py @@ -1,5 +1,6 @@ # Test methods with long descriptive names can omit docstrings -# pylint: disable=missing-docstring +# pylint: disable=missing-docstring,unsubscriptable-object +from unittest.mock import Mock import numpy as np from Orange.data import Table @@ -12,6 +13,7 @@ from Orange.widgets.data.owpreprocess import OWPreprocess, \ UnivariateFeatureSelect, Scale as ScaleEditor from Orange.widgets.tests.base import WidgetTest, datasets +from orangewidget.widget import StateInfo class TestOWPreprocess(WidgetTest): @@ -138,6 +140,25 @@ def test_data_column_nans(self): self.widget.set_model(model) self.send_signal(self.widget.Inputs.data, table) + def test_summary(self): + """Check if status bar is updated when data is received""" + data = Table("iris") + input_sum = self.widget.info.set_input_summary = Mock() + output_sum = self.widget.info.set_output_summary = Mock() + + self.send_signal(self.widget.Inputs.data, data) + input_sum.assert_called_with(int(StateInfo.format_number(len(data)))) + output = self.get_output(self.widget.Outputs.preprocessed_data) + output_sum.assert_called_with(int(StateInfo.format_number(len(output)))) + + input_sum.reset_mock() + output_sum.reset_mock() + self.send_signal(self.widget.Inputs.data, None) + input_sum.assert_called_once() + self.assertEqual(input_sum.call_args[0][0].brief, "") + output_sum.assert_called_once() + self.assertEqual(output_sum.call_args[0][0].brief, "") + # Test for editors class TestDiscretizeEditor(WidgetTest):