Skip to content

Commit 0aa97fd

Browse files
committed
Merge pull request #1939 from ales-erjavec/fixes/linearprojection-nan-columns
[ENH] Widget testing utilities (cherry picked from commit 40c677d) Conflicts: MANIFEST.in Orange/widgets/tests/base.py
1 parent 8de1497 commit 0aa97fd

File tree

10 files changed

+487
-72
lines changed

10 files changed

+487
-72
lines changed

MANIFEST.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ recursive-include Orange/tests *.tab *.basket *.xlsx
77
recursive-include Orange/canvas *.qss *ico *.png *.svg *.ico *.html
88
recursive-include Orange/canvas/application/workflows *.ows
99

10-
recursive-include Orange/widgets *.png *.svg
11-
recursive-include Orange/widgets/_highcharts *.js *.css *.html
12-
recursive-include Orange/widgets/utils/_webview *.js
10+
recursive-include Orange/widgets *.png *.svg *.js *.css *.html
11+
recursive-include Orange/widgets/tests *.tab
1312
recursive-include Orange/widgets/utils/plot *.fs *.vs *.gs *.obj
1413

1514
recursive-include distribute *.svg *.desktop

Orange/widgets/tests/base.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unittest
23

34
import numpy as np
@@ -20,7 +21,6 @@
2021
ANNOTATED_DATA_SIGNAL_NAME)
2122

2223
# For tests, let memory freeing entirely to Python / OS
23-
import sip
2424
sip.setdestroyonexit(False)
2525

2626
app = None
@@ -163,6 +163,9 @@ def send_signal(self, input_name, value, *args, widget=None):
163163
if input_signal.name == input_name:
164164
getattr(widget, input_signal.handler)(value, *args)
165165
break
166+
else:
167+
raise ValueError("'{}' is not an input name for widget {}"
168+
.format(input_name, type(widget).__name__))
166169
widget.handleNewSignals()
167170

168171
def get_output(self, output_name, widget=None):
@@ -540,3 +543,55 @@ def _compare_selected_annotated_domains(self, selected, annotated):
540543
selected_vars = selected.domain.variables + selected.domain.metas
541544
annotated_vars = annotated.domain.variables + annotated.domain.metas
542545
self.assertLess(set(selected_vars), set(annotated_vars))
546+
547+
548+
class datasets:
549+
@staticmethod
550+
def path(filename):
551+
dirname = os.path.join(os.path.dirname(__file__), "datasets")
552+
return os.path.join(dirname, filename)
553+
554+
@classmethod
555+
def missing_data_1(cls):
556+
"""
557+
Data set with 3 continuous features (X{1,2,3}) where all the columns
558+
and rows contain at least one NaN value.
559+
560+
One discrete class D with NaN values
561+
Mixed continuous/discrete/string metas ({X,D,S}M)
562+
563+
Returns
564+
-------
565+
data : Orange.data.Table
566+
"""
567+
return Table(cls.path("missing_data_1.tab"))
568+
569+
@classmethod
570+
def missing_data_2(cls):
571+
"""
572+
Data set with 3 continuous features (X{1,2,3}) where all the columns
573+
and rows contain at least one NaN value and X1, X2 are constant.
574+
575+
One discrete constant class D with NaN values.
576+
Mixed continuous/discrete/string class metas ({X,D,S}M)
577+
578+
Returns
579+
-------
580+
data : Orange.data.Table
581+
"""
582+
return Table(cls.path("missing_data_2.tab"))
583+
584+
@classmethod
585+
def missing_data_3(cls):
586+
"""
587+
Data set with 3 discrete features D{1,2,3} where all the columns and
588+
rows contain at least one NaN value
589+
590+
One discrete class D with NaN values
591+
Mixes continuous/discrete/string metas ({X,D,S}M)
592+
593+
Returns
594+
-------
595+
data : Orange.data.Table
596+
"""
597+
return Table(cls.path("missing_data_3.tab"))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
X1 X2 X3 D XM DM SM
2+
c c c d c d string
3+
class meta meta meta
4+
? 2 3 a 1 a a
5+
2 ? 1 b 2 b
6+
3 1 ? ? ? b b
7+
2 ? 1 b ? ?
8+
? 2 3 a 5 b c
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
X1 X2 X3 D XM DM SM
2+
c c c d c d string
3+
class meta meta meta
4+
? 1 3 a 1 a a
5+
1 ? 1 a 2 b
6+
1 1 ? ? ? b b
7+
1 ? 1 a ? ?
8+
? 1 3 a 5 b c
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
D1 D2 D3 D XM DM SM
2+
d d d d c d s
3+
class meta meta meta
4+
? b c a 1 a a
5+
b ? a b 1 b a
6+
c a ? ? 2 ?
7+
b ? a b ? ? b
8+
? b c a 3 b c

0 commit comments

Comments
 (0)