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

Merged
merged 1 commit into from
Mar 23, 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
8 changes: 6 additions & 2 deletions Orange/widgets/data/owoutliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from Orange.widgets.utils.concurrent import TaskState, ConcurrentWidgetMixin
from Orange.widgets.utils.sql import check_sql_input
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.widget import Msg, Input, Output, OWWidget


Expand Down Expand Up @@ -265,7 +266,9 @@ def set_data(self, data):
self.cancel()
self.clear_messages()
self.data = data
self.info.set_input_summary(len(data) if data else self.info.NoOutput)
summary = len(data) if data else self.info.NoInput
details = format_summary_details(data) if data else ""
self.info.set_input_summary(summary, details)
self.enable_controls()
self.unconditional_commit()

Expand Down Expand Up @@ -294,7 +297,8 @@ def on_partial_result(self, _):
def on_done(self, result: Results):
inliers, outliers = result.inliers, result.outliers
summary = len(inliers) if inliers else self.info.NoOutput
self.info.set_output_summary(summary)
details = format_summary_details(inliers) if inliers else ""
self.info.set_output_summary(summary, details)
self.n_inliers = len(inliers) if inliers else None
self.n_outliers = len(outliers) if outliers else None

Expand Down
10 changes: 10 additions & 0 deletions Orange/widgets/data/tests/test_owoutliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from Orange.classification import LocalOutlierFactorLearner
from Orange.widgets.data.owoutliers import OWOutliers, run
from Orange.widgets.tests.base import WidgetTest, simulate
from Orange.widgets.utils.state_summary import format_summary_details


class TestRun(unittest.TestCase):
Expand Down Expand Up @@ -132,16 +133,25 @@ def test_in_out_summary(self):
info = self.widget.info
self.assertEqual(info._StateInfo__input_summary.brief, "")
self.assertEqual(info._StateInfo__output_summary.brief, "")
self.assertEqual(info._StateInfo__input_summary.details, "No data on input")
self.assertEqual(info._StateInfo__output_summary.details, "No data on output")

self.send_signal(self.widget.Inputs.data, self.iris)
self.wait_until_finished()
self.assertEqual(info._StateInfo__input_summary.brief, "150")
self.assertIn(info._StateInfo__output_summary.brief, ["135", "136"])
self.assertEqual(info._StateInfo__input_summary.details,
format_summary_details(self.iris))
output = self.get_output(self.widget.Outputs.inliers)
self.assertEqual(info._StateInfo__output_summary.details,
format_summary_details(output))

self.send_signal(self.widget.Inputs.data, None)
self.wait_until_finished()
self.assertEqual(info._StateInfo__input_summary.brief, "")
self.assertEqual(info._StateInfo__output_summary.brief, "")
self.assertEqual(info._StateInfo__input_summary.details, "No data on input")
self.assertEqual(info._StateInfo__output_summary.details, "No data on output")

@patch("Orange.widgets.data.owoutliers.OWOutliers.MAX_FEATURES", 3)
@patch("Orange.widgets.data.owoutliers.OWOutliers.commit", Mock())
Expand Down