Skip to content

Commit 7939273

Browse files
committed
OWPreprocess: data info displayed in status bar
1 parent 667af57 commit 7939273

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Orange/widgets/data/owpreprocess.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,9 @@ def mimeData(indexlist):
11441144
box = gui.vBox(self.controlArea, "Output")
11451145
gui.auto_send(box, self, "autocommit", box=False)
11461146

1147+
self.info.set_input_summary(self.info.NoInput)
1148+
self.info.set_output_summary(self.info.NoOutput)
1149+
11471150
self._initialize()
11481151

11491152
def _initialize(self):
@@ -1261,6 +1264,10 @@ def __on_modelchanged(self):
12611264
def set_data(self, data=None):
12621265
"""Set the input dataset."""
12631266
self.data = data
1267+
if data is not None:
1268+
self.info.set_input_summary(len(data))
1269+
else:
1270+
self.info.set_input_summary(self.info.NoInput)
12641271

12651272
def handleNewSignals(self):
12661273
self.apply()
@@ -1304,8 +1311,10 @@ def apply(self):
13041311
except (ValueError, ZeroDivisionError) as e:
13051312
self.error(str(e))
13061313
return
1314+
self.info.set_output_summary(len(data))
13071315
else:
13081316
data = None
1317+
self.info.set_output_summary(self.info.NoOutput)
13091318

13101319
self.Outputs.preprocessor.send(preprocessor)
13111320
self.Outputs.preprocessed_data.send(data)

Orange/widgets/data/tests/test_owpreprocess.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Test methods with long descriptive names can omit docstrings
2-
# pylint: disable=missing-docstring
2+
# pylint: disable=missing-docstring,unsubscriptable-object
3+
from unittest.mock import Mock
34
import numpy as np
45

56
from Orange.data import Table
@@ -12,6 +13,7 @@
1213
from Orange.widgets.data.owpreprocess import OWPreprocess, \
1314
UnivariateFeatureSelect, Scale as ScaleEditor
1415
from Orange.widgets.tests.base import WidgetTest, datasets
16+
from orangewidget.widget import StateInfo
1517

1618

1719
class TestOWPreprocess(WidgetTest):
@@ -138,6 +140,25 @@ def test_data_column_nans(self):
138140
self.widget.set_model(model)
139141
self.send_signal(self.widget.Inputs.data, table)
140142

143+
def test_summary(self):
144+
"""Check if status bar is updated when data is received"""
145+
data = Table("iris")
146+
input_sum = self.widget.info.set_input_summary = Mock()
147+
output_sum = self.widget.info.set_output_summary = Mock()
148+
149+
self.send_signal(self.widget.Inputs.data, data)
150+
input_sum.assert_called_with(int(StateInfo.format_number(len(data))))
151+
output = self.get_output(self.widget.Outputs.preprocessed_data)
152+
output_sum.assert_called_with(int(StateInfo.format_number(len(output))))
153+
154+
input_sum.reset_mock()
155+
output_sum.reset_mock()
156+
self.send_signal(self.widget.Inputs.data, None)
157+
input_sum.assert_called_once()
158+
self.assertEqual(input_sum.call_args[0][0].brief, "")
159+
output_sum.assert_called_once()
160+
self.assertEqual(output_sum.call_args[0][0].brief, "")
161+
141162

142163
# Test for editors
143164
class TestDiscretizeEditor(WidgetTest):

0 commit comments

Comments
 (0)