Skip to content

Commit d6ef63a

Browse files
authored
Merge pull request #4498 from aturanjanin/owrandomize
[ENH] OWRandomize: Data info displayed in the status bar
2 parents 524b40d + 8eaa670 commit d6ef63a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Orange/widgets/data/owrandomize.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from Orange.preprocess import Randomize
88
from Orange.widgets.settings import Setting
99
from Orange.widgets.utils.widgetpreview import WidgetPreview
10+
from Orange.widgets.utils.state_summary import format_summary_details
1011
from Orange.widgets.widget import OWWidget, Input, Output
1112
from Orange.widgets import gui
1213

@@ -68,7 +69,7 @@ def __init__(self):
6869
callback=self._shuffle_check_changed)
6970

7071
self.info.set_input_summary(self.info.NoInput)
71-
self.info.set_output_summary(self.info.NoInput)
72+
self.info.set_output_summary(self.info.NoOutput)
7273

7374
self.apply_button = gui.auto_apply(self.controlArea, self, box=False, commit=self.apply)
7475

@@ -89,9 +90,10 @@ def _set_scope_label(self):
8990
@Inputs.data
9091
def set_data(self, data):
9192
self.data = data
93+
summary = len(data) if data else self.info.NoInput
94+
details = format_summary_details(data) if data else ""
95+
self.info.set_input_summary(summary, details)
9296
self.unconditional_apply()
93-
text = str(len(data)) if data else self.info.NoInput
94-
self.info.set_input_summary(text)
9597

9698
def apply(self):
9799
data = None
@@ -105,8 +107,9 @@ def apply(self):
105107
data = self.data.copy()
106108
for i, instance in zip(indices, randomized):
107109
data[i] = instance
108-
text = str(len(data)) if data else self.info.NoInput
109-
self.info.set_output_summary(text)
110+
summary = len(data) if data else self.info.NoOutput
111+
details = format_summary_details(data) if data else ""
112+
self.info.set_output_summary(summary, details)
110113
self.Outputs.data.send(data)
111114

112115
def send_report(self):

Orange/widgets/data/tests/test_owrandomize.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from Orange.data import Table
88
from Orange.widgets.data.owrandomize import OWRandomize
99
from Orange.widgets.tests.base import WidgetTest
10+
from Orange.widgets.utils.state_summary import format_summary_details
1011

1112

1213
class TestOWRandomize(WidgetTest):
@@ -79,13 +80,15 @@ def test_summary(self):
7980
output_sum = self.widget.info.set_output_summary = Mock()
8081
input_sum = self.widget.info.set_input_summary = Mock()
8182

82-
self.send_signal(self.widget.Inputs.data, self.zoo)
83-
input_sum.assert_called_with(str(len(self.zoo)))
83+
data = self.zoo
84+
self.send_signal(self.widget.Inputs.data, data)
85+
input_sum.assert_called_with(len(data),
86+
format_summary_details(data))
8487
output = self.get_output(self.widget.Outputs.data)
85-
output_sum.assert_called_with(str(len(output)))
88+
output_sum.assert_called_with(len(output),
89+
format_summary_details(output))
8690
input_sum.reset_mock()
8791
output_sum.reset_mock()
88-
8992
self.send_signal(self.widget.Inputs.data, None)
9093
input_sum.assert_called_once()
9194
self.assertEqual(input_sum.call_args[0][0].brief, "")

0 commit comments

Comments
 (0)