Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] pandas migration #1347

Closed
wants to merge 140 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
bb960ae
Extend str in Variable.
sstanovnik Jun 10, 2016
5a8846c
pandas migration: first huge, breaking, table update.
sstanovnik Jun 17, 2016
97fab90
Enable strict read-only access on Table X/Y/meta views.
sstanovnik Jun 17, 2016
3e7a853
Further changes to Table, as per recent comments.
sstanovnik Jun 22, 2016
81ddf10
Add Table.attributes to the pandas persistence scheme.
sstanovnik Jun 23, 2016
89907af
Insert pandas into requirements-core.
sstanovnik Jun 23, 2016
b732ed7
Table constructors and other fixes.
sstanovnik Jun 23, 2016
7af5a67
OWSelectRows: transform usage of Filter into pandas syntax.
sstanovnik Jun 23, 2016
85f6920
Completely remove Filter.
sstanovnik Jun 23, 2016
b8ee3b5
Table Domain changes, Variable inference and miscellaneous fixes.
sstanovnik Jun 25, 2016
7d3e29b
Make indexing and weights work from empty Tables.
sstanovnik Jun 28, 2016
ebb5a1f
Remove RowInstance completely.
sstanovnik Jun 28, 2016
5853ec5
Remove and transform infrequently-used old syntax.
sstanovnik Jun 28, 2016
77bf036
Completely remove Instance.
sstanovnik Jun 28, 2016
43f1a7f
Remove Storage.
sstanovnik Jun 28, 2016
d7a159d
Some minor fixes and cleanup in Table.
sstanovnik Jun 28, 2016
8623abc
A multitude of small fixes of bugs shown by tests.
sstanovnik Jun 29, 2016
3f7369b
Use pandas' reader for csv and tab.
sstanovnik Jun 29, 2016
827d4e1
Tab reader fixes for less common behaviour.
sstanovnik Jun 30, 2016
36d5b94
Port ExcelReader to use pandas' Excel reader.
sstanovnik Jun 30, 2016
8535478
Improve DiscreteVariable discreteness determination and parsing.
sstanovnik Jun 30, 2016
ba08eaf
Transform values we interpret as null with actual null values when
sstanovnik Jun 30, 2016
ce5cf4f
Handle NA weights when setting them.
sstanovnik Jun 30, 2016
f3a064b
Use pandas' categorical coltype for DiscreteVariable.
sstanovnik Jul 1, 2016
c170ade
Convert TimeVariable functionality to pandas.
sstanovnik Jul 1, 2016
745ca03
Small fixes: sniffer size, NA weights handling.
sstanovnik Jul 1, 2016
4a656b1
Variable equality fix and TimeVariable test modification.
sstanovnik Jul 1, 2016
ac914f0
A lot of small fixes for issues found by tests.
sstanovnik Jul 4, 2016
eca5618
Fix handling null values in TimeVariable columns.
sstanovnik Jul 5, 2016
fae01ac
Improve reading tab and csv files.
sstanovnik Jul 5, 2016
601d82d
Remove an unneeded test.
sstanovnik Jul 5, 2016
99ecf47
Compatibility shims for SQL table.
sstanovnik Jul 5, 2016
135eb47
Make Data Table work, transfer basic stats to pandas.
sstanovnik Jul 5, 2016
78f0db1
Multiple fixes: TableSeries retain attributes, constructor works
sstanovnik Jul 11, 2016
699b240
Remove Value.
sstanovnik Jul 11, 2016
360d0df
Fix recent TimeVariable changes.
sstanovnik Jul 11, 2016
38b648c
Some basic fixes for subscripting pandas.
sstanovnik Jul 11, 2016
9a4ef13
Migrate distributions to pandas.
sstanovnik Jul 11, 2016
2711440
Ported contingency to pandas.
sstanovnik Jul 12, 2016
e6f0cd9
Remove statistics/util.py.
sstanovnik Jul 12, 2016
bef5741
Adapt distances and tests to work with the new Table.
sstanovnik Jul 13, 2016
81bad83
Adapt preprocessors (discretize, impute) to work with the new Table.
sstanovnik Jul 13, 2016
5020b89
Loads of test and compatibility fixes.
sstanovnik Jul 13, 2016
90c43ec
k-Means compatibility fixes.
sstanovnik Jul 13, 2016
2dab765
Transform Continuize for usage with pandas.
sstanovnik Jul 13, 2016
54677f0
Fix parsing files with discrete variables which specify values.
sstanovnik Jul 13, 2016
9146bfa
Discretization pandas compatibility, also test fixes.
sstanovnik Jul 14, 2016
494caf0
Evaluation - scoring test compatibility fix.
sstanovnik Jul 14, 2016
f43eb2c
Intepret missing value markers when reading from file.
sstanovnik Jul 14, 2016
d2297f8
Impute pandas adaptation, with tests.
sstanovnik Jul 14, 2016
fc5b426
Fix transforming discrete ordinal values into descriptor values.
sstanovnik Jul 14, 2016
7dde951
Distributions should use weights instead of counts.
sstanovnik Jul 14, 2016
238a838
Miscellaneous test adaptations.
sstanovnik Jul 14, 2016
9d5093d
Convert normalization, use groupby instead of value_count in distribu…
sstanovnik Jul 14, 2016
72e2eb0
Add copying to table constructors, very important!
sstanovnik Jul 14, 2016
dc8027d
Migrate randomization to pandas.
sstanovnik Jul 15, 2016
7317045
A small fix for caching table transformations.
sstanovnik Jul 15, 2016
8c10f2a
Miscellaneous test compatibility fixes.
sstanovnik Jul 15, 2016
9d3cf40
Migrate remover and its tests.
sstanovnik Jul 15, 2016
d019e8d
Simple tree and softmax adaptation.
sstanovnik Jul 15, 2016
db2a2a9
Only allow one of specified delimiters when reading file.
sstanovnik Jul 15, 2016
2b53079
Remove Value tests.
sstanovnik Jul 15, 2016
55d233a
Miscellaneous table test compatibility fixes.
sstanovnik Jul 15, 2016
5cd878f
Use 0 instead of NA when values don't exist in distributions.
sstanovnik Jul 18, 2016
1fde4f2
Feature scoring test compatibility.
sstanovnik Jul 18, 2016
aa1d4c6
A bucketload of fixes for widgets.
sstanovnik Jul 18, 2016
3efd943
Fix owcontinuize to use proper continuization behaviour.
sstanovnik Jul 19, 2016
f5ee17d
Don't intepret None as a missing value when reading a table.
sstanovnik Jul 19, 2016
a44e1e4
Use proper top-level imports. D'oh!
sstanovnik Jul 19, 2016
14efa24
Use a more robust way of computing basic stats.
sstanovnik Jul 19, 2016
74bc375
A small fix for the new single-class test.
sstanovnik Jul 19, 2016
bc64dbc
Fixes for some elusive tests.
sstanovnik Jul 19, 2016
d21a3e8
Port SQLTable to a pandas backend. Some breaking changes.
sstanovnik Jul 21, 2016
23d42c4
Completely overhaul the Table class inheritance structure.
sstanovnik Jul 21, 2016
5c23db1
Fix some broken Table imports.
sstanovnik Jul 22, 2016
6004bed
Basic SparseTable functionality.
sstanovnik Jul 27, 2016
bc84af8
Distributions for sparse tables.
sstanovnik Jul 27, 2016
c190a5a
A snail-paced implementationof contingency computation for sparse
sstanovnik Jul 27, 2016
5864dd1
Improved the reading capabilities.
sstanovnik Jul 27, 2016
30b7f13
Fix elusive tests.
sstanovnik Jul 27, 2016
7e5b420
Use add numexpr to requirements-core.
sstanovnik Jul 27, 2016
9b94cb1
Use actual values instead of indices when constructing discretes.
sstanovnik Jul 28, 2016
c672319
Merge domain when not rowstacking concatenated tables.
sstanovnik Jul 28, 2016
645e50b
Widget test adaptation and widget fixes.
sstanovnik Jul 28, 2016
ed500db
REVIEWME: 'fixed' displaying SQL tables.
sstanovnik Jul 29, 2016
cd93a3f
Test fixes, remove sql.compat.Value
sstanovnik Jul 29, 2016
0d7ee88
Hopefully fix some strange failing tests.
sstanovnik Jul 29, 2016
5d2f8a7
Remove val_from_str_add.
sstanovnik Jul 29, 2016
430be00
Add to_var_col, a slightly optimized version of to_val.
sstanovnik Jul 29, 2016
a9f63c2
Remove TableBase.DENSE and related indicators.
sstanovnik Jul 29, 2016
e1f708d
Remove PanelBase and SparseTablePanel.
sstanovnik Jul 29, 2016
d17088e
Docstring bonanza!
sstanovnik Aug 1, 2016
265b590
Remove some old, unused, deprecated things from TableBase.
sstanovnik Aug 1, 2016
21bcc56
Remove variable.to_val_col.
sstanovnik Aug 1, 2016
6f0f16e
Documentation slightly updated.
sstanovnik Aug 1, 2016
0bd7160
Increase test coverage, some bugfixes.
sstanovnik Aug 2, 2016
9c2c6ba
Improve distributions, also coverage.
sstanovnik Aug 2, 2016
4f6993b
Increase contingency coverage.
sstanovnik Aug 2, 2016
caa733d
Fix OWHeatmap and its recent tests.
sstanovnik Aug 2, 2016
4843efc
Bump minimum version of pandas above 0.18.0.
sstanovnik Aug 9, 2016
b3031c9
Sparse fixes and improvements.
sstanovnik Aug 9, 2016
411d027
Excel sheet naming.
sstanovnik Aug 9, 2016
7ad4909
A multitude of fixes.
sstanovnik Aug 10, 2016
25c5c2b
A truckload of changes.
sstanovnik Aug 11, 2016
496f808
Remove Table.append.
sstanovnik Aug 11, 2016
4f50571
From list with missing class fixes, indent, lesser __setitem__ breakage.
sstanovnik Aug 11, 2016
96755ab
Remove the many missing-value replaces.
sstanovnik Aug 11, 2016
811e3e9
Prevent multiple calls to __init__.
sstanovnik Aug 11, 2016
8517bf2
Proper finalization and domain filtering.
sstanovnik Aug 12, 2016
41ae304
Custom __str__ and __repr__, needs some work.
sstanovnik Aug 12, 2016
33afcf0
REVIEWME: custom __iter__, iterates over rows, breaks pandas contract.
sstanovnik Aug 12, 2016
dfc1aba
Merge Data fix, new fun TableBase.merge method!
sstanovnik Aug 12, 2016
2e156fa
Fix venn diagram.
sstanovnik Aug 12, 2016
2add840
Fix Data Table.
sstanovnik Aug 12, 2016
ac6539d
Switch inputs from Table to TableBase.
sstanovnik Aug 12, 2016
98c6353
Much better __str__, uses pandas magic.
sstanovnik Aug 16, 2016
2fd14db
Except Orange instead of pandas behaviour in constructors.
sstanovnik Aug 16, 2016
78e9450
Use pure nnumpy ops for transforming discretes into categoricals.
sstanovnik Aug 16, 2016
287b049
Change usages of checksum to hash.
sstanovnik Aug 16, 2016
f2ef9ba
Add a notificatoin comment and test for the iterrows wrapper.
sstanovnik Aug 16, 2016
fc9d867
Remove shuffle in favour of .sample(frac=1).
sstanovnik Aug 16, 2016
b576a7e
Consolidate usages of the _transferer hack.
sstanovnik Aug 16, 2016
d0a03dd
Comments and tests to setUpClass, other test fixes.
sstanovnik Aug 16, 2016
118a8d1
Add time component awareness to TimeVariable.
sstanovnik Aug 17, 2016
a70e2c5
Fix a failing doctest.
sstanovnik Aug 17, 2016
8dbc1c7
Improve time column display with month and day.
sstanovnik Aug 19, 2016
b22e0d8
Add a pandas git build to travis.
sstanovnik Aug 19, 2016
98b745f
Some general fixes, report test fixes.
sstanovnik Aug 19, 2016
50e0989
Requirements.txt requires a different requirement format.
sstanovnik Aug 19, 2016
b561d2f
Further improvements to the documentation.
sstanovnik Aug 19, 2016
27c596f
Revert 68b18c5: overriding __iter__.
sstanovnik Aug 19, 2016
6ea711a
Simplify weight assignment.
sstanovnik Aug 19, 2016
06bcc77
Cherry-pick: sstanovnik/orange3:benches.
sstanovnik Aug 19, 2016
2bfca35
Weight setting robustness.
sstanovnik Aug 21, 2016
6460ab0
Properer sparse handling.
sstanovnik Aug 21, 2016
259bfc1
Always convert weights to floats on assignment.
sstanovnik Aug 26, 2016
ac75022
Fix visualizing continuous variables in Data Table.
sstanovnik Aug 26, 2016
3317ff0
Significantly improve feature constructor performance.
sstanovnik Aug 26, 2016
fc48858
Domain editor fix and file reader hardening.
sstanovnik Aug 26, 2016
3e6030f
Fix a failing owkmeans test.
sstanovnik Aug 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Comments and tests to setUpClass, other test fixes.
  • Loading branch information
sstanovnik committed Aug 26, 2016
commit d0a03dd4ca37843e09219e5ab1eab1f2c5fa7e68
2 changes: 1 addition & 1 deletion Orange/data/table/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _any_to_coo(mat):
return result

def _compute_distributions(self, columns=None):
# this needs reimplementing because of possible columns without values
# FIXME: this needs reimplementing because of possible columns without values
if columns is None:
columns = self.domain.attributes + self.domain.class_vars + self.domain.metas
distributions = []
Expand Down
7 changes: 2 additions & 5 deletions Orange/data/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class Variable(str, metaclass=VariableMeta):
----------
name : str
The name of the variable.
unknown_str : set
A set of values that represent unknowns in conversion from textual
formats. Default is Variable.MISSING_VALUES.
compute_value : Callable
A function for computing the variable's value when converting from
another domain which does not contain this variable. The base class
Expand Down Expand Up @@ -72,7 +69,6 @@ def __init__(self, name="", compute_value=None):
super().__init__()
self.name = name
self._compute_value = compute_value
self.unknown_str = Variable.MISSING_VALUES
self.source_variable = None
self.attributes = {}
self.master = self
Expand Down Expand Up @@ -216,7 +212,7 @@ def to_val(self, s):
"""
if not self.is_primitive():
return s
if s in self.unknown_str:
if s in self.MISSING_VALUES:
return Unknown
raise RuntimeError(
"primitive variable descriptors must overload to_val()")
Expand Down Expand Up @@ -711,6 +707,7 @@ def column_to_datetime(self, column):
# handle missing values like they don't exist
if val in Variable.MISSING_VALUES or (isinstance(val, Number) and np.isnan(val)):
continue
# for multiple timezones, use the last one for display
self.timezone = TimeVariable._detect_timezone(val) if not np.issubdtype(column.dtype, np.number) else None
# if any value doesn't have a timezone, permanently strip display timezones for the column
if self.timezone is None:
Expand Down
9 changes: 5 additions & 4 deletions Orange/tests/test_ada_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@


class TestSklAdaBoostLearner(unittest.TestCase):
def setUp(self):
self.iris = Table("iris")
self.housing = Table("housing")
self.titanic = Table("titanic")
@classmethod
def setUpClass(cls):
cls.iris = Table("iris")
cls.housing = Table("housing")
cls.titanic = Table("titanic")

def test_adaboost(self):
learn = SklAdaBoostLearner()
Expand Down
5 changes: 3 additions & 2 deletions Orange/tests/test_basic_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


class TestBasicStats(TestCase):
def setUp(self):
self.zoo = Table("zoo")
@classmethod
def setUpClass(cls):
cls.zoo = Table("zoo")

def test_domain_basic_stats(self):
domain = self.zoo.domain
Expand Down
7 changes: 4 additions & 3 deletions Orange/tests/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def test_continuous(self):


class UnknownValuesInPrediction(unittest.TestCase):
def setUp(self):
@classmethod
def setUpClass(cls):
Variable._clear_all_caches()

def test_unknown(self):
Expand All @@ -248,8 +249,8 @@ def test_missing_class(self):


class LearnerAccessibility(unittest.TestCase):

def setUp(self):
@classmethod
def setUpClass(cls):
Variable._clear_all_caches()

def all_learners(self):
Expand Down
5 changes: 3 additions & 2 deletions Orange/tests/test_continuize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@


class TestDomainContinuizer(unittest.TestCase):
def setUp(self):
@classmethod
def setUpClass(cls):
Variable._clear_all_caches()
self.data = Table(test_filename("test4"))
cls.data = Table(test_filename("test4"))

def test_default(self):
for inp in (self.data, self.data.domain):
Expand Down
7 changes: 4 additions & 3 deletions Orange/tests/test_discretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ def test_entropy(self):

# noinspection PyPep8Naming
class TestDiscretizer(TestCase):
def setUp(self):
self.var = Mock(data.ContinuousVariable, number_of_decimals=1)
self.var.name = "x"
@classmethod
def setUpClass(cls):
cls.var = Mock(data.ContinuousVariable, number_of_decimals=1)
cls.var.name = "x"

def test_create_discretized_var(self):
dvar = discretize.Discretizer.create_discretized_var(
Expand Down
87 changes: 49 additions & 38 deletions Orange/tests/test_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

def tables_equal(tab1, tab2):
# catch none
return (tab1 is None and tab1 == tab2) or tab1.equals(tab2)
return (tab1 is None and tab1 is tab2) or tab1.equals(tab2)


class TestDistMatrix(TestCase):
def setUp(self):
self.iris = Table('iris')
self.dist = Euclidean(self.iris)
@classmethod
def setUpClass(cls):
cls.iris = Table('iris')
cls.dist = Euclidean(cls.iris)

def test_submatrix(self):
sub = self.dist.submatrix([2, 3, 4])
Expand Down Expand Up @@ -173,10 +174,11 @@ def test_save(self):


class TestEuclidean(TestCase):
def setUp(self):
self.iris = Table('iris')
self.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
self.dist = Euclidean
@classmethod
def setUpClass(cls):
cls.iris = Table('iris')
cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
cls.dist = Euclidean

def test_euclidean_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.iris.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -241,10 +243,11 @@ def test_euclidean_distance_numpy(self):


class TestManhattan(TestCase):
def setUp(self):
self.iris = Table('iris')
self.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
self.dist = Manhattan
@classmethod
def setUpClass(cls):
cls.iris = Table('iris')
cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
cls.dist = Manhattan

def test_manhattan_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.iris.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -308,10 +311,11 @@ def test_manhattan_distance_numpy(self):


class TestCosine(TestCase):
def setUp(self):
self.iris = Table('iris')
self.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
self.dist = Cosine
@classmethod
def setUpClass(cls):
cls.iris = Table('iris')
cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))
cls.dist = Cosine

def test_cosine_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.iris.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -375,9 +379,10 @@ def test_cosine_distance_numpy(self):


class TestJaccard(TestCase):
def setUp(self):
self.titanic = Table('titanic')[173:177]
self.dist = Jaccard
@classmethod
def setUpClass(cls):
cls.titanic = Table('titanic')[173:177]
cls.dist = Jaccard

def test_jaccard_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.titanic.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -428,9 +433,10 @@ def test_jaccard_distance_numpy(self):


class TestSpearmanR(TestCase):
def setUp(self):
self.breast = Table("breast-cancer-wisconsin-cont")
self.dist = SpearmanR
@classmethod
def setUpClass(cls):
cls.breast = Table("breast-cancer-wisconsin-cont")
cls.dist = SpearmanR

def test_spearmanr_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.breast.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -506,9 +512,10 @@ def test_spearmanr_distance_numpy(self):


class TestSpearmanRAbsolute(TestCase):
def setUp(self):
self.breast = Table("breast-cancer-wisconsin-cont")
self.dist = SpearmanRAbsolute
@classmethod
def setUpClass(cls):
cls.breast = Table("breast-cancer-wisconsin-cont")
cls.dist = SpearmanRAbsolute

def test_spearmanrabsolute_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.breast.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -582,9 +589,10 @@ def test_spearmanrabsolute_distance_numpy(self):


class TestPearsonR(TestCase):
def setUp(self):
self.breast = Table("breast-cancer-wisconsin-cont")
self.dist = PearsonR
@classmethod
def setUpClass(cls):
cls.breast = Table("breast-cancer-wisconsin-cont")
cls.dist = PearsonR

def test_pearsonr_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.breast.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -655,9 +663,10 @@ def test_pearsonr_distance_numpy(self):


class TestPearsonRAbsolute(TestCase):
def setUp(self):
self.breast = Table("breast-cancer-wisconsin-cont")
self.dist = PearsonRAbsolute
@classmethod
def setUpClass(cls):
cls.breast = Table("breast-cancer-wisconsin-cont")
cls.dist = PearsonRAbsolute

def test_pearsonrabsolute_distance_one_example(self):
np.testing.assert_almost_equal(self.dist(self.breast.iloc[0]), np.array([[0]]))
Expand Down Expand Up @@ -726,11 +735,12 @@ def test_pearsonrabsolute_distance_numpy(self):


class TestMahalanobis(TestCase):
def setUp(self):
self.n, self.m = 10, 5
self.X = np.random.rand(self.n, self.m)
self.x1 = np.random.rand(self.m)
self.x2 = np.random.rand(self.m)
@classmethod
def setUpClass(cls):
cls.n, cls.m = 10, 5
cls.X = np.random.rand(cls.n, cls.m)
cls.x1 = np.random.rand(cls.m)
cls.x2 = np.random.rand(cls.m)

def test_correctness(self):
mah = MahalanobisDistance(self.X)
Expand Down Expand Up @@ -769,8 +779,9 @@ def test_axis(self):


class TestDistances(TestCase):
def setUp(self):
self.test5 = Table(test_filename('test5.tab'))
@classmethod
def setUpClass(cls):
cls.test5 = Table(test_filename('test5.tab'))

def test_preprocess(self):
domain = Domain([ContinuousVariable("c"),
Expand Down
14 changes: 7 additions & 7 deletions Orange/tests/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain, Variable
from Orange.tests import test_filename


class Distribution_DiscreteTestCase(unittest.TestCase):
def setUp(self):
self.freqs = [4.0, 20.0, 13.0, 8.0, 10.0, 41.0, 5.0]
s = sum(self.freqs)
self.rfreqs = [x/s for x in self.freqs]
@classmethod
def setUpClass(cls):
cls.freqs = [4.0, 20.0, 13.0, 8.0, 10.0, 41.0, 5.0]
s = sum(cls.freqs)
cls.rfreqs = [x/s for x in cls.freqs]

def test_from_table(self):
d = Table("zoo")
Expand Down Expand Up @@ -191,9 +193,7 @@ class Distribution_ContinuousTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.iris = Table("iris")

def setUp(self):
self.freqs = np.array([(1.0, 1), (1.1, 1), (1.2, 2), (1.3, 7), (1.4, 12),
cls.freqs = np.array([(1.0, 1), (1.1, 1), (1.2, 2), (1.3, 7), (1.4, 12),
(1.5, 14), (1.6, 7), (1.7, 4), (1.9, 2), (3.0, 1),
(3.3, 2), (3.5, 2), (3.6, 1), (3.7, 1), (3.8, 1),
(3.9, 3), (4.0, 5), (4.1, 3), (4.2, 4), (4.3, 2),
Expand Down
5 changes: 3 additions & 2 deletions Orange/tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ def test_domain_conversion_is_fast_enough(self):


class TestDomainFilter(unittest.TestCase):
def setUp(self):
self.iris = Table('iris')
@classmethod
def setUpClass(cls):
cls.iris = Table('iris')

def test_filter_visible(self):
n_feats = len(self.iris.domain.attributes)
Expand Down
5 changes: 3 additions & 2 deletions Orange/tests/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def compare_tables(self, dataNorm, solution):
self.assertEqual([attr.name for attr in dataNorm.domain.class_vars],
["cl1", "cl2"])

def setUp(self):
self.data = Table(test_filename("test5.tab"))
@classmethod
def setUpClass(cls):
cls.data = Table(test_filename("test5.tab"))

def test_normalize_default(self):
normalizer = Normalize()
Expand Down
5 changes: 3 additions & 2 deletions Orange/tests/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@


class TestRemover(unittest.TestCase):
def setUp(self):
self.test8 = Table(test_filename('test8.tab'))
@classmethod
def setUpClass(cls):
cls.test8 = Table(test_filename('test8.tab'))

def test_remove(self):
data = Table("iris").iloc[:5]
Expand Down
11 changes: 6 additions & 5 deletions Orange/tests/test_score_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@


class FeatureScoringTest(unittest.TestCase):
def setUp(self):
self.zoo = Table("zoo") # disc. features, disc. class
self.housing = Table("housing") # cont. features, cont. class
self.monk = Table("monks-1")
self.adult = Table("adult_sample")
@classmethod
def setUpClass(cls):
cls.zoo = Table("zoo") # disc. features, disc. class
cls.housing = Table("housing") # cont. features, cont. class
cls.monk = Table("monks-1")
cls.adult = Table("adult_sample")

def test_info_gain(self):
scorer = InfoGain()
Expand Down
Loading