Skip to content

Commit

Permalink
Refactored test args
Browse files Browse the repository at this point in the history
  • Loading branch information
KulikDM committed Sep 1, 2023
1 parent 60c4db7 commit 6626465
Show file tree
Hide file tree
Showing 20 changed files with 243 additions and 218 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ v<0.3.3>, <07/30/2023> -- Updated all thresholders to accept multiple detector s
v<0.3.3>, <07/30/2023> -- New benchmarking for multiple score sets
v<0.3.3>, <08/03/2023> -- Added time complexity to benchmark
v<0.3.4>, <09/01/2023> -- FrechetMean hot fix for karch
v<0.3.4>, <09/01/2023> -- Refactored test args
19 changes: 11 additions & 8 deletions pythresh/test/test_chau.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -45,13 +46,15 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.methods:
self.thres = CHAU(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
params = product(self.all_scores, self.methods)

assert_equal(pred_labels.shape, self.y_train.shape)
for scores, method in params:

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
self.thres = CHAU(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)

assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
23 changes: 12 additions & 11 deletions pythresh/test/test_clf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -45,19 +46,19 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
params = product(self.all_scores, self.methods)

for method in self.methods:
for scores, method in params:

self.thres = CLF(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is None)
assert (self.thres.dscores_ is not None)
self.thres = CLF(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is None)
assert (self.thres.dscores_ is not None)

assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)
assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)

assert_equal(pred_labels.shape, self.y_train.shape)
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
20 changes: 11 additions & 9 deletions pythresh/test/test_clust.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -46,15 +47,16 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.methods:
params = product(self.all_scores, self.methods)

self.thres = CLUST(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is None)
assert (self.thres.dscores_ is None)
for scores, method in params:

assert_equal(pred_labels.shape, self.y_train.shape)
self.thres = CLUST(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is None)
assert (self.thres.dscores_ is None)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
19 changes: 11 additions & 8 deletions pythresh/test/test_comb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -45,13 +46,15 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.methods:
self.thres = COMB(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.confidence_interval_ is not None)
params = product(self.all_scores, self.methods)

assert_equal(pred_labels.shape, self.y_train.shape)
for scores, method in params:

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
self.thres = COMB(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.confidence_interval_ is not None)

assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
25 changes: 13 additions & 12 deletions pythresh/test/test_cpd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -46,19 +47,19 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.methods:
for transform in self.transforms:
params = product(self.all_scores, self.methods, self.transforms)

self.thres = CPD(method=method, transform=transform)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)
for scores, method, transform in params:

assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)
self.thres = CPD(method=method, transform=transform)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)

assert_equal(pred_labels.shape, self.y_train.shape)
assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
18 changes: 10 additions & 8 deletions pythresh/test/test_decomp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -45,14 +46,15 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.methods:
params = product(self.all_scores, self.methods)

self.thres = DECOMP(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
for scores, method in params:

assert_equal(pred_labels.shape, self.y_train.shape)
self.thres = DECOMP(method=method)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
20 changes: 11 additions & 9 deletions pythresh/test/test_dsn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -46,16 +47,17 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for metric in self.metrics:
params = product(self.all_scores, self.metrics)

self.thres = DSN(metric=metric)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
for scores, metric in params:

assert_equal(pred_labels.shape, self.y_train.shape)
self.thres = DSN(metric=metric)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)

if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
24 changes: 13 additions & 11 deletions pythresh/test/test_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -41,23 +42,24 @@ def setUp(self):

self.all_scores = [scores, multiple_scores]

self.method = ['gaussian', 'savgol', 'hilbert', 'wiener', 'medfilt',
'decimate', 'detrend', 'resample']
self.methods = ['gaussian', 'savgol', 'hilbert', 'wiener', 'medfilt',
'decimate', 'detrend', 'resample']

self.sigma = 'auto'

def test_prediction_labels(self):

for scores in self.all_scores:
for method in self.method:
params = product(self.all_scores, self.methods)

self.thres = FILTER(method=method, sigma=self.sigma)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
for scores, method in params:

assert_equal(pred_labels.shape, self.y_train.shape)
self.thres = FILTER(method=method, sigma=self.sigma)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)

if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
27 changes: 14 additions & 13 deletions pythresh/test/test_gamgmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import unittest
import warnings
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -55,22 +56,22 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for skip in self.skip:
for verbose in self.verbose:
params = product(self.all_scores, self.skip, self.verbose)

self.thres = GAMGMM(skip=skip, steps=10, verbose=verbose)
for scores, skip, verbose in params:

pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)
self.thres = GAMGMM(skip=skip, steps=10, verbose=verbose)

assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)

assert_equal(pred_labels.shape, self.y_train.shape)
assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)

if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
if (not np.all(pred_labels == 0)) & (not np.all(pred_labels == 1)):

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
25 changes: 13 additions & 12 deletions pythresh/test/test_gesd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import unittest
from itertools import product
from os.path import dirname as up

# noinspection PyProtectedMember
Expand Down Expand Up @@ -46,20 +47,20 @@ def setUp(self):

def test_prediction_labels(self):

for scores in self.all_scores:
for max_outliers in self.max_outliers:
for alpha in self.alphas:
params = product(self.all_scores, self.max_outliers, self.alphas)

self.thres = GESD(max_outliers=max_outliers, alpha=alpha)
for scores, max_outliers, alpha in params:

pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)
self.thres = GESD(max_outliers=max_outliers, alpha=alpha)

assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)
assert (self.thres.dscores_ is not None)

assert_equal(pred_labels.shape, self.y_train.shape)
assert (self.thres.dscores_.min() == 0)
assert (self.thres.dscores_.max() == 1)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
assert_equal(pred_labels.shape, self.y_train.shape)

assert (pred_labels.min() == 0)
assert (pred_labels.max() == 1)
Loading

0 comments on commit 6626465

Please sign in to comment.