Skip to content

Commit 77147bf

Browse files
committed
tests/owlinearprojection: Test on input dataset with NaN values
1 parent 8f68ebe commit 77147bf

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

Orange/widgets/visualize/tests/test_owlinearprojection.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Test methods with long descriptive names can omit docstrings
22
# pylint: disable=missing-docstring
33
import random
4+
import numpy as np
5+
6+
from AnyQt.QtCore import Qt, QModelIndex, QAbstractItemModel
7+
from AnyQt.QtWidgets import QComboBox
8+
from AnyQt.QtTest import QTest
49

510
from Orange.data import Table
611
from Orange.widgets.visualize.owlinearprojection import OWLinearProjection
7-
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin
12+
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin, datasets
13+
from Orange.widgets.tests.utils import EventSpy, excepthook_catch, simulate
814

915

1016
class TestOWLinearProjection(WidgetTest, WidgetOutputsTestMixin):
@@ -17,7 +23,7 @@ def setUpClass(cls):
1723
cls.signal_data = cls.data
1824

1925
def setUp(self):
20-
self.widget = self.create_widget(OWLinearProjection)
26+
self.widget = self.create_widget(OWLinearProjection) # type: OWLinearProjection
2127

2228
def _select_data(self):
2329
random.seed(42)
@@ -28,3 +34,45 @@ def _select_data(self):
2834
def test_no_data(self):
2935
"""Check that the widget doesn't crash on empty data"""
3036
self.send_signal("Data", Table(Table("iris").domain))
37+
38+
def test_nan_plot(self):
39+
data = datasets.data_1()
40+
espy = EventSpy(self.widget, OWLinearProjection.ReplotRequest)
41+
with excepthook_catch() as exclist:
42+
self.send_signal("Data", data)
43+
# ensure delayed replot request is processed
44+
if not espy.events():
45+
assert espy.wait(1000)
46+
47+
cb_color = self.widget.controls.color_index
48+
cb_size = self.widget.controls.size_index
49+
cb_shape = self.widget.controls.shape_index
50+
cb_jitter = self.widget.controls.jitter_value
51+
52+
simulate.combobox_run_through_all(cb_color)
53+
simulate.combobox_run_through_all(cb_size)
54+
simulate.combobox_run_through_all(cb_shape)
55+
with excepthook_catch():
56+
simulate.combobox_activate_index(cb_jitter, 1, delay=1)
57+
58+
data = data.copy()
59+
data.X[:, 0] = np.nan
60+
data.Y[:] = np.nan
61+
62+
spy = EventSpy(self.widget, OWLinearProjection.ReplotRequest)
63+
self.send_signal("Data", data)
64+
self.send_signal("Data Subset", data[2:3])
65+
if not spy.events():
66+
assert spy.wait()
67+
68+
with excepthook_catch():
69+
simulate.combobox_activate_item(cb_color, "X1")
70+
71+
with excepthook_catch():
72+
simulate.combobox_activate_item(cb_size, "X1")
73+
74+
with excepthook_catch():
75+
simulate.combobox_activate_item(cb_shape, "D")
76+
77+
with excepthook_catch():
78+
simulate.combobox_activate_index(cb_jitter, 2, delay=1)

0 commit comments

Comments
 (0)