Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] OWSelectColumns: Data info displayed in the status bar #4454

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Orange/widgets/data/owselectcolumns.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from Orange.widgets.settings import ContextSetting, Setting
from Orange.widgets.utils.listfilter import VariablesListItemView, slices, variables_filter
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.widget import Input, Output, AttributeList, Msg
from Orange.data.table import Table
from Orange.widgets.utils import vartype
Expand Down Expand Up @@ -266,6 +267,9 @@ def dropcompleted(action):
self.output_data = None
self.original_completer_items = []

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

self.resize(600, 600)

@property
Expand Down Expand Up @@ -343,11 +347,13 @@ def set_data(self, data=None):
self.class_attrs[:] = classes
self.meta_attrs[:] = metas
self.available_attrs[:] = available
self.info.set_input_summary(len(data), format_summary_details(data))
else:
self.used_attrs[:] = []
self.class_attrs[:] = []
self.meta_attrs[:] = []
self.available_attrs[:] = []
self.info.set_input_summary(self.info.NoInput)

def update_domain_role_hints(self):
""" Update the domain hints to be stored in the widgets settings.
Expand Down Expand Up @@ -522,10 +528,13 @@ def commit(self):
self.output_data = newdata
self.Outputs.data.send(newdata)
self.Outputs.features.send(AttributeList(attributes))
self.info.set_output_summary(len(newdata),
format_summary_details(newdata))
else:
self.output_data = None
self.Outputs.data.send(None)
self.Outputs.features.send(None)
self.info.set_output_summary(self.info.NoOutput)

def reset(self):
self.enable_used_attrs()
Expand Down
22 changes: 22 additions & 0 deletions Orange/widgets/data/tests/test_owselectcolumns.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=unsubscriptable-object
from unittest import TestCase
from unittest.mock import Mock

Expand All @@ -9,6 +10,7 @@
SelectAttributesDomainContextHandler
from Orange.widgets.settings import ContextSetting
from Orange.widgets.utils import vartype
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.data.owselectcolumns \
import OWSelectAttributes, VariablesListItemModel
Expand Down Expand Up @@ -386,3 +388,23 @@ def test_move_rows(self):
d1.domain.attributes,
data.domain.attributes
)

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(len(data), format_summary_details(data))
output = self.get_output(self.widget.Outputs.data)
output_sum.assert_called_with(len(output),
format_summary_details(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, "")