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 cd44a14
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
23 changes: 19 additions & 4 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,10 +388,15 @@ def apply(self):
self.commit()

def commit(self):
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)
if self.cont_data is None:
if self.data is None:
self.Outputs.data.send(self.data)
self.Outputs.features.send(None)
self.Outputs.correlations.send(None)
self.info.set_output_summary(self.info.NoOutput)
else:
self.info.set_output_summary(len(self.data),
format_summary_details(self.data))
return

attrs = [ContinuousVariable("Correlation"), ContinuousVariable("FDR")]
Expand All @@ -402,6 +415,8 @@ def commit(self):
corr_table.name = "Correlations"

self.Outputs.data.send(self.data)
self.info.set_output_summary(len(self.data),
format_summary_details(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 cd44a14

Please sign in to comment.