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

[ENH] dependency and diff test switch for individual estimators to decorate non-suite tests #5084

Merged
merged 44 commits into from Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1864dfc
test switch
fkiraly Aug 12, 2023
6eccb5e
switch teaser
fkiraly Aug 12, 2023
9fe9b67
clearsky
fkiraly Aug 12, 2023
afa04ba
tsfresh
fkiraly Aug 12, 2023
2e2474c
stc
fkiraly Aug 12, 2023
ff0aa38
randomintervals
fkiraly Aug 12, 2023
9a896c7
autoets
fkiraly Aug 12, 2023
715ef34
hivecote
fkiraly Aug 12, 2023
d0319c8
boss classes
fkiraly Aug 12, 2023
6c48558
linting
fkiraly Aug 12, 2023
e28e169
Update test_switch.py
fkiraly Aug 12, 2023
79e8377
add dependencies to hivecote
fkiraly Aug 12, 2023
b4f71dd
main in softdeps-full
fkiraly Aug 12, 2023
b52c2d5
reducers
fkiraly Aug 12, 2023
6cd26ec
pluginparamsforecaster
fkiraly Aug 12, 2023
2e5e9cb
conformal doctest
fkiraly Aug 12, 2023
75a0f53
Merge branch 'main' into test-switch
fkiraly Aug 12, 2023
7cd7612
linting
fkiraly Aug 12, 2023
a75f414
kshapes
fkiraly Aug 12, 2023
9961c6d
Merge branch 'main' into test-switch
fkiraly Aug 12, 2023
0442552
catch22
fkiraly Aug 12, 2023
1864365
linting
fkiraly Aug 12, 2023
4159cb3
shapelets
fkiraly Aug 12, 2023
57ae27d
Update test_shapelet_transform.py
fkiraly Aug 12, 2023
93ff9d7
conformal params
fkiraly Aug 12, 2023
0cb767c
knn
fkiraly Aug 12, 2023
f640467
clasp
fkiraly Aug 12, 2023
6a6f9c9
tde
fkiraly Aug 12, 2023
de70378
Merge branch 'main' into test-switch
fkiraly Aug 13, 2023
f1aa65b
allow lists
fkiraly Aug 13, 2023
3c42532
ARIMA for evaluate
fkiraly Aug 13, 2023
56f5f4e
ardl
fkiraly Aug 13, 2023
58bba89
pmdarima
fkiraly Aug 13, 2023
05ed287
prophet
fkiraly Aug 13, 2023
2fd153a
tbats
fkiraly Aug 13, 2023
b67e96a
ComposableTimeSeriesForestClassifier
fkiraly Aug 13, 2023
e382560
drcif
fkiraly Aug 13, 2023
e542aaa
arsenal
fkiraly Aug 13, 2023
4ba035e
clusterers
fkiraly Aug 13, 2023
d96704b
Merge branch 'main' into test-switch
fkiraly Aug 13, 2023
f45bea5
Merge branch 'main' into test-switch
fkiraly Aug 13, 2023
9439313
Update sktime/tests/test_switch.py
fkiraly Aug 13, 2023
9ea19f7
linting
fkiraly Aug 13, 2023
129326a
Update test_evaluate.py
fkiraly Aug 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -91,10 +91,16 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- run: git remote set-branches origin 'main'

- run: git fetch --depth 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Display Python version
run: python -c "import sys; print(sys.version)"

Expand Down
10 changes: 5 additions & 5 deletions sktime/annotation/tests/test_clasp.py
Expand Up @@ -8,12 +8,12 @@

from sktime.annotation.clasp import ClaSPSegmentation
from sktime.datasets import load_gun_point_segmentation
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(ClaSPSegmentation),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_clasp_sparse():
"""Test ClaSP sparse segmentation.
Expand All @@ -34,8 +34,8 @@ def test_clasp_sparse():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(ClaSPSegmentation),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_clasp_dense():
"""Tests ClaSP dense segmentation.
Expand Down
10 changes: 5 additions & 5 deletions sktime/classification/dictionary_based/tests/test_boss.py
Expand Up @@ -4,7 +4,7 @@

from sktime.classification.dictionary_based import BOSSEnsemble, IndividualBOSS
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_estimator_deps
from sktime.tests.test_switch import run_test_for_class


@pytest.fixture
Expand All @@ -19,8 +19,8 @@ def dataset():


@pytest.mark.skipif(
not _check_estimator_deps(IndividualBOSS, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(IndividualBOSS),
reason="run test only if softdeps are present and incrementally (if requested)",
)
@pytest.mark.parametrize(
"new_class,expected_dtype",
Expand Down Expand Up @@ -50,8 +50,8 @@ def test_individual_boss_classes(dataset, new_class, expected_dtype):


@pytest.mark.skipif(
not _check_estimator_deps(BOSSEnsemble, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(BOSSEnsemble),
reason="run test only if softdeps are present and incrementally (if requested)",
)
@pytest.mark.parametrize(
"new_class,expected_dtype",
Expand Down
10 changes: 5 additions & 5 deletions sktime/classification/dictionary_based/tests/test_tde.py
Expand Up @@ -4,12 +4,12 @@

from sktime.classification.dictionary_based._tde import TemporalDictionaryEnsemble
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TemporalDictionaryEnsemble),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_tde_train_estimate():
"""Test of TDE train estimate on unit test data."""
Expand All @@ -33,8 +33,8 @@ def test_tde_train_estimate():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TemporalDictionaryEnsemble),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_contracted_tde():
"""Test of contracted TDE on unit test data."""
Expand Down
Expand Up @@ -8,6 +8,7 @@
KNeighborsTimeSeriesClassifier,
)
from sktime.datasets import load_unit_test
from sktime.tests.test_switch import run_test_for_class
from sktime.utils.validation._dependencies import _check_estimator_deps

distance_functions = [
Expand Down Expand Up @@ -43,6 +44,10 @@
}


@pytest.mark.skipif(
not run_test_for_class(KNeighborsTimeSeriesClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
@pytest.mark.parametrize("distance_key", distance_functions)
def test_knn_on_unit_test(distance_key):
"""Test function for elastic knn, to be reinstated soon."""
Expand All @@ -61,6 +66,10 @@ def test_knn_on_unit_test(distance_key):
assert correct == expected_correct[distance_key]


@pytest.mark.skipif(
not run_test_for_class(KNeighborsTimeSeriesClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
@pytest.mark.parametrize("distance_key", distance_functions)
def test_knn_bounding_matrix(distance_key):
"""Test knn with custom bounding parameters."""
Expand Down Expand Up @@ -111,6 +120,10 @@ def test_knn_with_aggrdistance():
clf.fit(X, y)


@pytest.mark.skipif(
not run_test_for_class(KNeighborsTimeSeriesClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_knn_kneighbors():
"""Tests kneighbors method and absence of bug #3798."""
from sktime.utils._testing.hierarchical import _make_hierarchical
Expand Down
Expand Up @@ -8,7 +8,7 @@
from sktime.classification.interval_based import TimeSeriesForestClassifier
from sktime.datasets import load_unit_test
from sktime.datatypes._panel._convert import from_nested_to_3d_numpy
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


def load_unit_data():
Expand All @@ -20,8 +20,8 @@ def load_unit_data():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TEASER),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_teaser_on_unit_test_data():
"""Test of TEASER on unit test data."""
Expand Down Expand Up @@ -50,8 +50,8 @@ def test_teaser_on_unit_test_data():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TEASER),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_teaser_with_different_decision_maker():
"""Test of TEASER with different One-Class-Classifier."""
Expand Down Expand Up @@ -82,8 +82,8 @@ def test_teaser_with_different_decision_maker():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TEASER),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_teaser_near_classification_points():
"""Test of TEASER with incremental time stamps outside defined class points."""
Expand Down Expand Up @@ -116,8 +116,8 @@ def test_teaser_near_classification_points():


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TEASER),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_teaser_full_length():
"""Test of TEASER on the full data with the default estimator."""
Expand Down
9 changes: 9 additions & 0 deletions sktime/classification/ensemble/tests/test_ensemble.py
Expand Up @@ -10,6 +10,7 @@

from sktime.classification.ensemble import ComposableTimeSeriesForestClassifier
from sktime.datasets import load_unit_test
from sktime.tests.test_switch import run_test_for_class
from sktime.transformations.compose import FeatureUnion
from sktime.transformations.panel.segment import RandomIntervalSegmenter
from sktime.transformations.panel.summarize import RandomIntervalFeatureExtractor
Expand All @@ -29,6 +30,10 @@


# Check simple cases.
@pytest.mark.skipif(
not run_test_for_class(ComposableTimeSeriesForestClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_tsf_predict_proba():
"""Test composable TSF predict proba."""
clf = ComposableTimeSeriesForestClassifier(n_estimators=2)
Expand Down Expand Up @@ -95,6 +100,10 @@ def test_equivalent_model_specifications(n_intervals, n_estimators):


# Compare TimeSeriesForest ensemble predictions using pipeline as estimator
@pytest.mark.skipif(
not run_test_for_class(ComposableTimeSeriesForestClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
@pytest.mark.parametrize("n_intervals", ["sqrt", 1])
@pytest.mark.parametrize("n_estimators", [1, 3])
def test_tsf_predictions(n_estimators, n_intervals):
Expand Down
1 change: 1 addition & 0 deletions sktime/classification/hybrid/_hivecote_v1.py
Expand Up @@ -97,6 +97,7 @@ class HIVECOTEV1(BaseClassifier):
"capability:multithreading": True,
"capability:predict_proba": True,
"classifier_type": "hybrid",
"python_dependencies": "numba",
}

def __init__(
Expand Down
1 change: 1 addition & 0 deletions sktime/classification/hybrid/_hivecote_v2.py
Expand Up @@ -95,6 +95,7 @@ class HIVECOTEV2(BaseClassifier):
"capability:multithreading": True,
"capability:predict_proba": True,
"classifier_type": "hybrid",
"python_dependencies": "numba",
}

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions sktime/classification/hybrid/tests/test_hivecote_v2.py
Expand Up @@ -4,12 +4,12 @@
from sktime.classification.hybrid import HIVECOTEV2
from sktime.classification.sklearn import RotationForest
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(HIVECOTEV2),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_contracted_hivecote_v2():
"""Test of contracted HIVECOTEV2 on unit test data."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/classification/interval_based/tests/test_drcif.py
Expand Up @@ -3,12 +3,12 @@

from sktime.classification.interval_based import DrCIF
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(DrCIF),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_contracted_drcif():
"""Test of contracted DrCIF on unit test data."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/classification/kernel_based/tests/test_arsenal.py
Expand Up @@ -3,12 +3,12 @@

from sktime.classification.kernel_based import Arsenal
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(Arsenal),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_contracted_arsenal():
"""Test of contracted Arsenal on unit test data."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/classification/shapelet_based/tests/test_stc.py
Expand Up @@ -4,12 +4,12 @@
from sktime.classification.shapelet_based import ShapeletTransformClassifier
from sktime.classification.sklearn import RotationForest
from sktime.datasets import load_unit_test
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(ShapeletTransformClassifier),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_contracted_stc():
"""Test of contracted ShapeletTransformClassifier on unit test data."""
Expand Down
10 changes: 5 additions & 5 deletions sktime/clustering/tests/test_k_means.py
Expand Up @@ -5,7 +5,7 @@

from sktime.clustering.k_means import TimeSeriesKMeans
from sktime.datasets import load_basic_motions
from sktime.utils.validation._dependencies import _check_estimator_deps
from sktime.tests.test_switch import run_test_for_class

expected_results = {
"mean": [
Expand Down Expand Up @@ -107,8 +107,8 @@


@pytest.mark.skipif(
not _check_estimator_deps(TimeSeriesKMeans, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(TimeSeriesKMeans),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_kmeans():
"""Test implementation of Kmeans."""
Expand Down Expand Up @@ -143,8 +143,8 @@ def test_kmeans():


@pytest.mark.skipif(
not _check_estimator_deps(TimeSeriesKMeans, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(TimeSeriesKMeans),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_kmeans_dba():
"""Test implementation of Kmeans using dba."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/clustering/tests/test_k_medoids.py
Expand Up @@ -5,7 +5,7 @@

from sktime.clustering.k_medoids import TimeSeriesKMedoids
from sktime.datasets import load_basic_motions
from sktime.utils.validation._dependencies import _check_soft_dependencies
from sktime.tests.test_switch import run_test_for_class

expected_results = {
"medoids": [
Expand Down Expand Up @@ -107,8 +107,8 @@


@pytest.mark.skipif(
not _check_soft_dependencies("numba", severity="none"),
reason="skip test if required soft dependency not available",
not run_test_for_class(TimeSeriesKMedoids),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_kmedoids():
"""Test implementation of Kmedoids."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/clustering/tests/test_k_shapes.py
Expand Up @@ -4,7 +4,7 @@

from sktime.clustering.k_shapes import TimeSeriesKShapes
from sktime.datasets import load_basic_motions
from sktime.utils.validation._dependencies import _check_estimator_deps
from sktime.tests.test_switch import run_test_for_class

expected_results = [
0,
Expand Down Expand Up @@ -100,8 +100,8 @@


@pytest.mark.skipif(
not _check_estimator_deps(TimeSeriesKShapes, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(TimeSeriesKShapes),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_kshapes():
"""Test implementation of Kshapes."""
Expand Down
6 changes: 3 additions & 3 deletions sktime/clustering/tests/test_kernel_k_means.py
Expand Up @@ -4,7 +4,7 @@

from sktime.clustering.kernel_k_means import TimeSeriesKernelKMeans
from sktime.datasets import load_basic_motions
from sktime.utils.validation._dependencies import _check_estimator_deps
from sktime.tests.test_switch import run_test_for_class

expected_results = [
0,
Expand Down Expand Up @@ -98,8 +98,8 @@


@pytest.mark.skipif(
not _check_estimator_deps(TimeSeriesKernelKMeans, severity="none"),
reason="skip test if required soft dependencies not available",
not run_test_for_class(TimeSeriesKernelKMeans),
reason="run test only if softdeps are present and incrementally (if requested)",
)
def test_kernel_k_means():
"""Test implementation of kernel k means."""
Expand Down