Skip to content

Commit

Permalink
OWDiscretize: data info displayed in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
aturanjanin committed Jan 14, 2020
1 parent ccee167 commit 53d5415
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Orange/widgets/data/owdiscretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def _intbox(parent, attr, callback):

self._update_spin_positions()

self.info.set_output_summary(self.info.NoInput)
self.info.set_input_summary(self.info.NoInput)


@Inputs.data
def set_data(self, data):
Expand All @@ -257,7 +260,9 @@ def set_data(self, data):
self._restore(self.saved_var_states)
# Complete the induction of cut points
self._update_points()
self.info.set_input_summary(len(data))
else:
self.info.set_input_summary(self.info.NoInput)
self._clear()
self.unconditional_commit()

Expand Down Expand Up @@ -478,6 +483,9 @@ def commit(self):
if self.data is not None and len(self.data):
domain = self.discretized_domain()
output = self.data.transform(domain)
self.info.set_output_summary(len(output))
else:
self.info.set_output_summary(self.info.NoInput)
self.Outputs.data.send(output)

def storeSpecificSettings(self):
Expand Down
24 changes: 23 additions & 1 deletion Orange/widgets/data/tests/test_owdiscretize.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring
# pylint: disable=missing-docstring,unsubscriptable-object
from unittest.mock import Mock

from Orange.data import Table
from Orange.widgets.data.owdiscretize import OWDiscretize
from Orange.widgets.tests.base import WidgetTest
from orangewidget.widget import StateInfo


class TestOWDiscretize(WidgetTest):
Expand All @@ -17,3 +20,22 @@ def test_empty_data(self):
self.send_signal(self.widget.Inputs.data,
Table.from_domain(data.domain))
widget.unconditional_commit()

def test_summary(self):
"""Check if status bar is updated when data is received"""
input_sum = self.widget.info.set_input_summary = Mock()
output_sum = self.widget.info.set_output_summary = Mock()

data = Table("iris")
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.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, "")

0 comments on commit 53d5415

Please sign in to comment.