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] OWSave: Data info displayed in the status bar #4505

Merged
merged 1 commit into from
Mar 13, 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
13 changes: 6 additions & 7 deletions Orange/widgets/data/owsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from Orange.widgets.settings import Setting
from Orange.widgets.utils.save.owsavebase import OWSaveBase
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.utils.state_summary import format_summary_details


_userhome = os.path.expanduser(f"~{os.sep}")
Expand Down Expand Up @@ -35,6 +36,8 @@ class Error(OWSaveBase.Error):
def __init__(self):
super().__init__(2)

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

self.grid.addWidget(
gui.checkBox(
None, self, "add_type_annotations",
Expand Down Expand Up @@ -79,13 +82,9 @@ def update_messages(self):
and self.filename and not self.writer.SUPPORT_SPARSE_DATA)

def update_status(self):
if self.data is None:
self.info.set_input_summary(self.info.NoInput)
else:
self.info.set_input_summary(
str(len(self.data)),
f"Data set {self.data.name or '(no name)'} "
f"with {len(self.data)} instances")
summary = len(self.data) if self.data else self.info.NoInput
details = format_summary_details(self.data) if self.data else ""
self.info.set_input_summary(summary, details)

def send_report(self):
self.report_data_brief(self.data)
Expand Down
11 changes: 7 additions & 4 deletions Orange/widgets/data/tests/test_owsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from Orange.widgets.data.owsave import OWSave, OWSaveBase
from Orange.widgets.utils.save.tests.test_owsavebase import \
SaveWidgetsTestBaseMixin
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.tests.base import WidgetTest, open_widget_classes


Expand Down Expand Up @@ -55,24 +56,26 @@ def test_dataset(self):

datasig = widget.Inputs.data
self.send_signal(datasig, self.iris)
self.assertEqual(insum.call_args[0][0], "150")
insum.assert_called_with(len(self.iris), format_summary_details(self.iris))
insum.reset_mock()
savefile.reset_mock()

widget.filename = "foo.tab"
widget.writer = TabReader
widget.auto_save = False
self.send_signal(datasig, self.iris)
self.assertEqual(insum.call_args[0][0], "150")
insum.assert_called_with(len(self.iris), format_summary_details(self.iris))
savefile.assert_not_called()

widget.auto_save = True
self.send_signal(datasig, self.iris)
self.assertEqual(insum.call_args[0][0], "150")
insum.assert_called_with(len(self.iris), format_summary_details(self.iris))
savefile.assert_called()

insum.reset_mock()
self.send_signal(datasig, None)
insum.assert_called_with(widget.info.NoInput)
insum.assert_called_once()
self.assertEqual(insum.call_args[0][0].brief, "")

def test_initial_start_dir(self):
widget = self.widget
Expand Down