Skip to content

Commit

Permalink
OWHeatMap: Output Flagged Data
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Oct 18, 2016
1 parent 4435821 commit 5610750
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
8 changes: 7 additions & 1 deletion Orange/widgets/visualize/owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

from Orange.clustering import hierarchical
from Orange.widgets.utils import colorbrewer
from Orange.widgets.utils.annotated_data import (create_annotated_table,
ANNOTATED_DATA_SIGNAL_NAME)
from Orange.widgets import widget, gui, settings
from Orange.widgets.io import FileFormat

Expand Down Expand Up @@ -381,7 +383,8 @@ class OWHeatMap(widget.OWWidget):
priority = 260

inputs = [("Data", Table, "set_dataset")]
outputs = [("Selected Data", Table, widget.Default)]
outputs = [("Selected Data", Table, widget.Default),
(ANNOTATED_DATA_SIGNAL_NAME, Table)]

settingsHandler = settings.DomainContextHandler()

Expand Down Expand Up @@ -1506,6 +1509,7 @@ def on_selection_finished(self):

def commit(self):
data = None
indices = None
if self.merge_kmeans:
assert self.merge_indices is not None
merge_indices = self.merge_indices
Expand All @@ -1524,6 +1528,8 @@ def commit(self):
data = self.input_data[indices]

self.send("Selected Data", data)
self.send(ANNOTATED_DATA_SIGNAL_NAME,
create_annotated_table(self.input_data, indices))

def onDeleteWidget(self):
self.clear()
Expand Down
31 changes: 19 additions & 12 deletions Orange/widgets/visualize/tests/test_owheatmap.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring
import random
from Orange.data import Table
from Orange.preprocess import Continuize
from Orange.widgets.visualize.owheatmap import OWHeatMap
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin


class TestOWHeatMap(WidgetTest):
class TestOWHeatMap(WidgetTest, WidgetOutputsTestMixin):
@classmethod
def setUpClass(cls):
super().setUpClass()
WidgetOutputsTestMixin.init(cls)

cls.housing = Table("housing")
cls.titanic = Table("titanic")

cls.signal_name = "Data"
cls.signal_data = cls.data

def setUp(self):
self.widget = self.create_widget(OWHeatMap)
self.iris = Table("iris")
self.housing = Table("housing")
self.titanic = Table("titanic")

def test_input_data(self):
"""Check widget's data with data on the input"""
for data in (self.iris, self.housing):
for data in (self.data, self.housing):
self.assertEqual(self.widget.data, None)
self.send_signal("Data", data)
self.assertEqual(self.widget.data, data)
Expand All @@ -28,7 +35,7 @@ def test_input_data(self):
def test_error_message(self):
self.send_signal("Data", self.titanic)
self.assertTrue(self.widget.Error.active)
self.send_signal("Data", self.iris)
self.send_signal("Data", self.data)
self.assertFalse(self.widget.Error.active)

def test_information_message(self):
Expand All @@ -37,11 +44,11 @@ def test_information_message(self):
cont_titanic = continuizer(self.titanic)
self.send_signal("Data", cont_titanic)
self.assertTrue(self.widget.Information.active)
self.send_signal("Data", self.iris)
self.send_signal("Data", self.data)
self.assertFalse(self.widget.Information.active)

def test_settings_changed(self):
self.send_signal("Data", self.iris)
self.send_signal("Data", self.data)
# check output when "Sorting Column" setting changes
self._select_data()
self.assertIsNotNone(self.get_output("Selected Data"))
Expand All @@ -61,6 +68,6 @@ def test_settings_changed(self):
self.assertIsNone(self.get_output("Selected Data"))

def _select_data(self):
rows = random.sample(range(0, len(self.iris)), 20)
self.widget.selection_manager.select_rows(rows)
self.selected_indices = list(range(10, 31))
self.widget.selection_manager.select_rows(self.selected_indices)
self.widget.on_selection_finished()

0 comments on commit 5610750

Please sign in to comment.