Fix test class to be runnable by pytest
Test class with __init__ is not run by pytest
@@ -15,21 +15,25 @@ def dist_func(x1, x2, p):
return np.sum((x1 - x2) ** p) ** (1. / p)
-class TestMetrics:
- def __init__(self, n1=20, n2=25, d=4, zero_frac=0.5,
- rseed=0, dtype=np.float64):
+class TestMetrics(object):
+ n1 = 20
+ n2 = 25
+ d = 4
+ zero_frac = 0.5
+ rseed = 0
+ dtype = np.float64
rng = check_random_state(rseed)
- self.X1 = rng.random_sample((n1, d)).astype(dtype)
- self.X2 = rng.random_sample((n2, d)).astype(dtype)
+ X1 = rng.random_sample((n1, d)).astype(dtype)
+ X2 = rng.random_sample((n2, d)).astype(dtype)
# make boolean arrays: ones and zeros
- self.X1_bool = self.X1.round(0)
- self.X2_bool = self.X2.round(0)
+ X1_bool = X1.round(0)
+ X2_bool = X2.round(0)
V = rng.random_sample((d, d))
VI = np.dot(V, V.T)
- self.metrics = {'euclidean': {},
+ metrics = {'euclidean': {},
'cityblock': {},
'minkowski': dict(p=(1, 1.5, 2, 3)),
'chebyshev': {},
@@ -41,7 +45,7 @@ class TestMetrics:
'canberra': {},
'braycurtis': {}}
- self.bool_metrics = ['matching', 'jaccard', 'dice',
+ bool_metrics = ['matching', 'jaccard', 'dice',
'kulsinski', 'rogerstanimoto', 'russellrao',
'sokalmichener', 'sokalsneath']
