Skip to content

Commit

Permalink
OWOutliers: data info displayed in the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
aturanjanin committed Mar 23, 2020
1 parent b838a6d commit 4fb67e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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, "")
self.assertEqual(info._StateInfo__output_summary.details, "")

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, "")
self.assertEqual(info._StateInfo__output_summary.details, "")

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

0 comments on commit 4fb67e1

Please sign in to comment.