Skip to content

Commit

Permalink
[MNT] testing remaining cleanup (#2349)
Browse files Browse the repository at this point in the history
* remove old stuff

* testing tidy

* testing tidy

* example results files
  • Loading branch information
MatthewMiddlehurst authored Nov 15, 2024
1 parent aea3119 commit 21cd32e
Show file tree
Hide file tree
Showing 37 changed files with 349 additions and 1,417 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
recursive-include aeon *.py
recursive-include aeon/benchmarking/example_results *.csv
recursive-include aeon/datasets *.csv *.arff *.txt *.ts *.tsv *.tsf
recursive-include aeon/testing/example_results_files *.csv
include aeon/registry/README.md
include .coveragerc
include conftest.py
Expand Down
7 changes: 5 additions & 2 deletions aeon/benchmarking/tests/test_results_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
from pytest import raises

import aeon
from aeon.benchmarking.results_loaders import (
CONNECTION_ERRORS,
NAME_ALIASES,
Expand Down Expand Up @@ -72,8 +73,10 @@ def test_get_available_estimators():

cls = ["HIVECOTEV2", "FreshPRINCE", "InceptionTime"]
data = ["Chinatown", "ItalyPowerDemand", "Tools"]
test_path = os.path.dirname(__file__)
data_path = os.path.join(test_path, "../example_results/")
data_path = os.path.join(
os.path.dirname(aeon.__file__),
"testing/example_results_files/",
)


@pytest.mark.skipif(
Expand Down
6 changes: 3 additions & 3 deletions aeon/classification/compose/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import StandardScaler

Expand All @@ -16,7 +17,6 @@
make_example_3d_numpy_list,
)
from aeon.testing.mock_estimators import MockCollectionTransformer
from aeon.testing.utils.estimator_checks import _assert_array_almost_equal
from aeon.transformations.collection import (
AutocorrelationFunctionTransformer,
HOG1DTransformer,
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_classifier_pipeline(transformers):
X_test = t.transform(X_test)

c.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, c.predict(X_test))
assert_array_almost_equal(y_pred, c.predict(X_test))


@pytest.mark.parametrize(
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_sklearn_classifier_pipeline(transformers):
X_test = t.transform(X_test)

c.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, c.predict(X_test))
assert_array_almost_equal(y_pred, c.predict(X_test))


def test_unequal_tag_inference():
Expand Down
6 changes: 3 additions & 3 deletions aeon/clustering/compose/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler

Expand All @@ -14,7 +15,6 @@
make_example_3d_numpy_list,
)
from aeon.testing.mock_estimators import MockCollectionTransformer
from aeon.testing.utils.estimator_checks import _assert_array_almost_equal
from aeon.transformations.collection import (
AutocorrelationFunctionTransformer,
HOG1DTransformer,
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_clusterer_pipeline(transformers):
X_test = t.transform(X_test)

c.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, c.predict(X_test))
assert_array_almost_equal(y_pred, c.predict(X_test))


@pytest.mark.parametrize(
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_sklearn_clusterer_pipeline(transformers):
X_test = t.transform(X_test)

c.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, c.predict(X_test))
assert_array_almost_equal(y_pred, c.predict(X_test))


def test_unequal_tag_inference():
Expand Down
2 changes: 1 addition & 1 deletion aeon/performance_metrics/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

data_path = os.path.join(
os.path.dirname(aeon.__file__),
"benchmarking/example_results/",
"testing/example_results_files/",
)


Expand Down
6 changes: 3 additions & 3 deletions aeon/regression/compose/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import StandardScaler

Expand All @@ -16,7 +17,6 @@
make_example_3d_numpy_list,
)
from aeon.testing.mock_estimators import MockCollectionTransformer
from aeon.testing.utils.estimator_checks import _assert_array_almost_equal
from aeon.transformations.collection import (
AutocorrelationFunctionTransformer,
HOG1DTransformer,
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_regressor_pipeline(transformers):
X_test = t.transform(X_test)

r.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, r.predict(X_test))
assert_array_almost_equal(y_pred, r.predict(X_test))


@pytest.mark.parametrize(
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_sklearn_regressor_pipeline(transformers):
X_test = t.transform(X_test)

r.fit(X_train, y_train)
_assert_array_almost_equal(y_pred, r.predict(X_test))
assert_array_almost_equal(y_pred, r.predict(X_test))


def test_unequal_tag_inference():
Expand Down
8 changes: 3 additions & 5 deletions aeon/segmentation/_eagglo.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ class EAggloSegmenter(BaseSegmenter):
Examples
--------
>>> from aeon.testing.data_generation import piecewise_normal_multivariate
>>> from aeon.testing.data_generation import make_example_dataframe_series
>>> from aeon.segmentation import EAggloSegmenter
>>> X = piecewise_normal_multivariate(means=[[1, 3], [4, 5]], lengths=[3, 4],
... random_state = 10)
>>> X = make_example_dataframe_series(n_channels=2, random_state=10)
>>> model = EAggloSegmenter()
>>> model.fit_predict(X, axis=0)
array([0, 0, 0, 1, 1, 1, 1])
>>> y = model.fit_predict(X, axis=0)
"""

_tags = {
Expand Down
6 changes: 2 additions & 4 deletions aeon/segmentation/_ggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,10 @@ class GreedyGaussianSegmenter(BaseSegmenter):
Examples
--------
>>> from aeon.testing.data_generation import piecewise_normal_multivariate
>>> from aeon.testing.data_generation import make_example_dataframe_series
>>> from sklearn.preprocessing import MinMaxScaler
>>> from aeon.segmentation import GreedyGaussianSegmenter
>>> X = piecewise_normal_multivariate(lengths=[10, 10, 10, 10],
... means=[[0.0, 1.0], [11.0, 10.0], [5.0, 3.0], [2.0, 2.0]],
... variances=0.5)
>>> X = make_example_dataframe_series(n_channels=2, random_state=10)
>>> X_scaled = MinMaxScaler(feature_range=(0, 1)).fit_transform(X)
>>> ggs = GreedyGaussianSegmenter(k_max=3, max_shuffles=5)
>>> y = ggs.fit_predict(X_scaled, axis=0)
Expand Down
22 changes: 4 additions & 18 deletions aeon/segmentation/_igts.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,6 @@ class _IGTS:
"Information gain-based metric for recognizing transitions in human activities.",
Pervasive and Mobile Computing, 38, 92-109, (2017).
https://www.sciencedirect.com/science/article/abs/pii/S1574119217300081
Examples
--------
>>> from aeon.testing.data_generation import piecewise_normal_multivariate
>>> from sklearn.preprocessing import MinMaxScaler
>>> from aeon.segmentation import InformationGainSegmenter
>>> X = piecewise_normal_multivariate(lengths=[10, 10, 10, 10],
... means=[[0.0, 1.0], [11.0, 10.0], [5.0, 3.0], [2.0, 2.0]],
... variances=0.5)
>>> X_scaled = MinMaxScaler(feature_range=(0, 1)).fit_transform(X)
>>> igts = InformationGainSegmenter(k_max=3, step=2)
>>> y = igts.fit_predict(X_scaled, axis=0)
"""

# init attributes
Expand Down Expand Up @@ -256,7 +243,8 @@ def find_change_points(self, X: npt.ArrayLike) -> list[int]:
current_change_points = self.identity(X)

for k in range(self.k_max):
ig_max = 0
best_candidate = -1
ig_max = -1
# find a point which maximizes score
for candidate in self.get_candidates(n_samples, current_change_points):
try_change_points = {candidate}
Expand Down Expand Up @@ -335,12 +323,10 @@ class InformationGainSegmenter(BaseSegmenter):
Examples
--------
>>> from aeon.testing.data_generation import piecewise_normal_multivariate
>>> from aeon.testing.data_generation import make_example_dataframe_series
>>> from sklearn.preprocessing import MinMaxScaler
>>> from aeon.segmentation import InformationGainSegmenter
>>> X = piecewise_normal_multivariate(lengths=[10, 10, 10, 10],
... means=[[0.0, 1.0], [11.0, 10.0], [5.0, 3.0], [2.0, 2.0]],
... variances=0.5)
>>> X = make_example_dataframe_series(n_channels=2, random_state=10)
>>> X_scaled = MinMaxScaler(feature_range=(0, 1)).fit_transform(X)
>>> igts = InformationGainSegmenter(k_max=3, step=2)
>>> y = igts.fit_predict(X_scaled, axis=0)
Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions aeon/testing/data_generation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
"make_example_2d_numpy_series",
"make_example_pandas_series",
"make_example_dataframe_series",
# other
"piecewise_normal_multivariate",
"piecewise_normal",
"piecewise_multinomial",
"piecewise_poisson",
"labels_with_repeats",
"label_piecewise_normal",
"_make_hierarchical",
"_bottom_hier_datagen",
]


Expand All @@ -41,15 +32,3 @@
make_example_dataframe_series,
make_example_pandas_series,
)
from aeon.testing.data_generation.hierarchical import (
_bottom_hier_datagen,
_make_hierarchical,
)
from aeon.testing.data_generation.segmentation import (
label_piecewise_normal,
labels_with_repeats,
piecewise_multinomial,
piecewise_normal,
piecewise_normal_multivariate,
piecewise_poisson,
)
Loading

0 comments on commit 21cd32e

Please sign in to comment.