Skip to content

[ENH] Some tests for coverage #2947

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions aeon/transformations/collection/dictionary_based/_sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ def _transform(self, X, y=None):
List of dictionaries containing SFA words
"""
X = X.squeeze(1)

# with warnings.catch_warnings():
# warnings.simplefilter("ignore", category=NumbaTypeSafetyWarning)
transform = Parallel(n_jobs=self._n_jobs, prefer="threads")(
delayed(self._transform_case)(
X[i, :],
Expand Down Expand Up @@ -327,10 +324,6 @@ def transform_mft(self, X):
-------
Array of Fourier coefficients
"""
# X = X.squeeze(1)

# with warnings.catch_warnings():
# warnings.simplefilter("ignore", category=NumbaTypeSafetyWarning)
transform = Parallel(n_jobs=self._n_jobs, prefer="threads")(
delayed(self._mft)(X[i, :]) for i in range(X.shape[0])
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import pytest

from aeon.datasets import load_unit_test
from aeon.testing.data_generation import (
make_example_3d_numpy,
)
from aeon.transformations.collection.dictionary_based import SFA, SFAFast


Expand Down Expand Up @@ -92,9 +95,6 @@ def test_dft_mft(use_fallback_dft, norm):
assert len(mft[0]) == word_length


test_dft_mft(True, True)


@pytest.mark.parametrize("binning_method", ["equi-depth", "information-gain"])
def test_sfa_anova(binning_method):
"""Test the SFA transformer with ANOVA one-sided test."""
Expand Down Expand Up @@ -249,3 +249,31 @@ def test_sfa_fast_transform_after_fit():
and np.all(x.indptr == y.indptr)
and np.allclose(x.data, y.data)
)


def test_incorrect_paras():
"""Test incorrect parameters in SFA."""
X, y = make_example_3d_numpy(n_cases=20, n_channels=1, n_timepoints=49)
sfa = SFA(alphabet_size=1, word_length=0, binning_method="information-gain")
with pytest.raises(ValueError, match="must be an integer greater than 2"):
sfa._fit(X)
sfa.alphabet_size = 4
with pytest.raises(ValueError, match="must be an integer greater than 1"):
sfa._fit(X)
sfa.word_length = 2
with pytest.raises(ValueError, match="Class values must be provided"):
sfa._fit(X)
sfa.binning_method = "Arsenal"
with pytest.raises(TypeError, match="binning_method must be one of"):
sfa._fit(X)
sfa = SFA(word_length=64, alphabet_size=8)
sfa.max_bits = 128
sfa._typed_dict = True
with pytest.raises(ValueError, match="Typed Dictionaries can only handle 64 bit"):
sfa._fit(X, y)
sfa = SFA(typed_dict=True, levels=16)
with pytest.raises(ValueError, match="Dictionaries can only handle 15 levels"):
sfa._fit(X, y)
sfa = SFA(typed_dict=True, save_words=True, n_jobs=2)
sfa.fit_transform(X, y)
assert isinstance(sfa.words, np.ndarray)
17 changes: 17 additions & 0 deletions aeon/transformations/series/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import numpy as np
import pytest

from aeon.testing.data_generation import (
make_example_1d_numpy,
make_example_2d_numpy_series,
)
from aeon.testing.mock_estimators import (
MockMultivariateSeriesTransformer,
MockSeriesTransformerNoFit,
Expand Down Expand Up @@ -53,3 +57,16 @@ def test_fit_transform_univariate():
x3 = transformer.transform(x1, x2)
x4 = transformer.fit_transform(x1, x2)
np.testing.assert_array_almost_equal(x3, x4)


def test_check_y():
"""Test check_y function in BaseTransformer."""
y = make_example_2d_numpy_series(100, 3)
t = MockSeriesTransformerNoFit()
with pytest.raises(TypeError, match="must be a np.array or a pd.Series"):
t._check_y("Arsenal")
with pytest.raises(TypeError, match="must be 1-dimensional"):
t._check_y(y)
y = make_example_1d_numpy(100)
with pytest.raises(ValueError, match="Mismatch in number of cases"):
t._check_y(y, 50)
Loading