-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
134 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,24 @@ | ||
# Test methods with long descriptive names can omit docstrings | ||
# pylint: disable=missing-docstring | ||
import random | ||
import numpy as np | ||
from Orange.data import Table | ||
from Orange.misc.flagged_data import FLAGGED_SIGNAL_NAME, FLAGGED_FEATURE_NAME | ||
from Orange.distance import Euclidean | ||
from Orange.widgets.unsupervised.owdistancemap import OWDistanceMap | ||
from Orange.widgets.tests.base import WidgetTest | ||
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin | ||
|
||
|
||
class TestOWDistanceMap(WidgetTest): | ||
def setUp(self): | ||
self.widget = self.create_widget(OWDistanceMap) | ||
self.iris = Table("iris") | ||
self.iris_distances = Euclidean(self.iris) | ||
|
||
def test_outputs(self): | ||
self.send_signal("Distances", self.iris_distances) | ||
class TestOWDistanceMap(WidgetTest, WidgetOutputsTestMixin): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
WidgetOutputsTestMixin.init(cls) | ||
|
||
# check selected data output | ||
self.assertIsNone(self.get_output("Selected Data")) | ||
cls.signal_name = "Distances" | ||
cls.signal_data = Euclidean(cls.data) | ||
|
||
# check flagged data output | ||
flagged = self.get_output(FLAGGED_SIGNAL_NAME) | ||
self.assertEqual(0, np.sum([i[FLAGGED_FEATURE_NAME] for i in flagged])) | ||
def setUp(self): | ||
self.widget = self.create_widget(OWDistanceMap) | ||
|
||
# select data points | ||
points = random.sample(range(0, len(self.iris)), 20) | ||
def _select_data(self): | ||
points = random.sample(range(0, len(self.data)), 20) | ||
self.widget._selection = points | ||
self.widget.commit() | ||
|
||
# check selected data output | ||
selected = self.get_output("Selected Data") | ||
self.assertEqual(len(selected), len(points)) | ||
|
||
# check flagged data output | ||
flagged = self.get_output(FLAGGED_SIGNAL_NAME) | ||
self.assertEqual(len(selected), | ||
np.sum([i[FLAGGED_FEATURE_NAME] for i in flagged])) | ||
|
||
# compare selected and flagged data domains | ||
selected_vars = selected.domain.variables + selected.domain.metas | ||
flagged_vars = flagged.domain.variables + flagged.domain.metas | ||
self.assertTrue(all((var in flagged_vars for var in selected_vars))) | ||
|
||
# check output when data is removed | ||
self.send_signal("Distances", None) | ||
self.assertIsNone(self.get_output("Selected Data")) | ||
self.assertIsNone(self.get_output(FLAGGED_SIGNAL_NAME)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,25 @@ | ||
# Test methods with long descriptive names can omit docstrings | ||
# pylint: disable=missing-docstring | ||
import random | ||
import numpy as np | ||
from PyQt4.QtCore import QEvent | ||
from Orange.data import Table | ||
from Orange.misc.flagged_data import FLAGGED_SIGNAL_NAME, FLAGGED_FEATURE_NAME | ||
from Orange.distance import Euclidean | ||
from Orange.widgets.unsupervised.owmds import OWMDS | ||
from Orange.widgets.tests.base import WidgetTest | ||
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin | ||
|
||
|
||
class TestOWMDS(WidgetTest): | ||
def setUp(self): | ||
self.widget = self.create_widget(OWMDS) | ||
self.iris = Table("iris") | ||
self.iris_distances = Euclidean(self.iris) | ||
class TestOWMDS(WidgetTest, WidgetOutputsTestMixin): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
WidgetOutputsTestMixin.init(cls) | ||
|
||
def test_outputs(self): | ||
self.send_signal("Distances", self.iris_distances) | ||
self.widget.customEvent(QEvent(QEvent.User)) | ||
self.widget.commit() | ||
cls.signal_name = "Distances" | ||
cls.signal_data = Euclidean(cls.data) | ||
cls.same_input_output_domain = False | ||
|
||
# check selected data output | ||
self.assertIsNone(self.get_output("Selected Data")) | ||
|
||
# check flagged data output | ||
flagged = self.get_output(FLAGGED_SIGNAL_NAME) | ||
self.assertEqual(0, np.sum([i[FLAGGED_FEATURE_NAME] for i in flagged])) | ||
def setUp(self): | ||
self.widget = self.create_widget(OWMDS) | ||
|
||
# select data points | ||
points = random.sample(range(0, len(self.iris)), 20) | ||
def _select_data(self): | ||
points = random.sample(range(0, len(self.data)), 20) | ||
self.widget.select_indices(points) | ||
self.widget.commit() | ||
|
||
# check selected data output | ||
selected = self.get_output("Selected Data") | ||
self.assertEqual(len(selected), len(points)) | ||
|
||
# check flagged data output | ||
flagged = self.get_output(FLAGGED_SIGNAL_NAME) | ||
self.assertEqual(len(selected), | ||
np.sum([i[FLAGGED_FEATURE_NAME] for i in flagged])) | ||
|
||
# compare selected and flagged data domains | ||
selected_vars = selected.domain.variables + selected.domain.metas | ||
flagged_vars = flagged.domain.variables + flagged.domain.metas | ||
self.assertTrue(all((var in flagged_vars for var in selected_vars))) | ||
|
||
# check output when data is removed | ||
self.send_signal("Distances", None) | ||
self.assertIsNone(self.get_output("Selected Data")) | ||
self.assertIsNone(self.get_output(FLAGGED_SIGNAL_NAME)) |
Oops, something went wrong.