Skip to content

Commit

Permalink
Data info displayed in the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
aturanjanin committed Feb 28, 2020
1 parent 4462394 commit 1ca1db5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Orange/widgets/data/owcorrelations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from Orange.widgets.utils.itemmodels import DomainModel
from Orange.widgets.utils.signals import Input, Output
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.visualize.utils import VizRankDialogAttrPair
from Orange.widgets.widget import OWWidget, AttributeList, Msg

Expand Down Expand Up @@ -292,6 +293,9 @@ def __init__(self):
button_box = gui.hBox(self.mainArea)
button_box.layout().addWidget(self.vizrank.button)

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

@staticmethod
def sizeHint():
return QSize(350, 400)
Expand Down Expand Up @@ -358,6 +362,10 @@ def set_data(self, data):
self.Warning.not_enough_vars()
else:
self.cont_data = SklImpute()(cont_data)
self.info.set_input_summary(len(data),
format_summary_details(data))
else:
self.info.set_input_summary(self.info.NoInput)
self.set_feature_model()
self.openContext(self.cont_data)
self.apply()
Expand All @@ -380,8 +388,12 @@ def apply(self):
self.commit()

def commit(self):
self.Outputs.data.send(self.data)
summary = len(self.data) if self.data else self.info.NoOutput
details = format_summary_details(self.data) if self.data else ""
self.info.set_output_summary(summary, details)

if self.data is None or self.cont_data is None:
self.Outputs.data.send(self.data)
self.Outputs.features.send(None)
self.Outputs.correlations.send(None)
return
Expand All @@ -401,7 +413,6 @@ def commit(self):
corr_table = Table(domain, x, metas=m)
corr_table.name = "Correlations"

self.Outputs.data.send(self.data)
# data has been imputed; send original attributes
self.Outputs.features.send(AttributeList(
[self.data.domain[name] for name, _ in self.selection]))
Expand Down
23 changes: 22 additions & 1 deletion Orange/widgets/data/tests/test_owcorrelations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring, protected-access
# pylint: disable=missing-docstring, protected-access, unsubscriptable-object
import time
import unittest
from unittest.mock import patch, Mock
Expand All @@ -19,6 +19,7 @@
from Orange.widgets.tests.utils import simulate
from Orange.widgets.visualize.owscatterplot import OWScatterPlot
from Orange.widgets.widget import AttributeList
from Orange.widgets.utils.state_summary import format_summary_details


class TestOWCorrelations(WidgetTest):
Expand Down Expand Up @@ -301,6 +302,26 @@ def test_send_report(self):
self.send_signal(self.widget.Inputs.data, None)
self.widget.report_button.click()

def test_summary(self):
"""Check if status bar is updated when data is received"""
data = Table("iris")
input_sum = self.widget.info.set_input_summary = Mock()
output_sum = self.widget.info.set_output_summary = Mock()

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, "")


class TestCorrelationRank(WidgetTest):
@classmethod
Expand Down

0 comments on commit 1ca1db5

Please sign in to comment.