Skip to content

Commit

Permalink
Merge pull request #4454 from aturanjanin/owselectcolumns
Browse files Browse the repository at this point in the history
[ENH] OWSelectColumns: Data info displayed in the status bar
  • Loading branch information
VesnaT authored Feb 28, 2020
2 parents bd2d334 + efefe6b commit 34063e6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
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, "")

0 comments on commit 34063e6

Please sign in to comment.