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

[MNT] Distance module refactor part 2 #2178

Merged
merged 26 commits into from
Oct 30, 2024
Merged
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
6 changes: 3 additions & 3 deletions aeon/classification/distance_based/_proximity_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _get_best_splitter(self, X, y):
X[j],
splitter[0][labels[k]],
metric=measure,
kwargs=splitter[1][measure],
**splitter[1][measure],
)
if dist < min_dist:
min_dist = dist
Expand Down Expand Up @@ -321,7 +321,7 @@ def _build_tree(self, X, y, depth, node_id, parent_target_value=None):
X[i],
splitter[0][labels[j]],
metric=measure,
kwargs=splitter[1][measure],
**splitter[1][measure],
)
if dist < min_dist:
min_dist = dist
Expand Down Expand Up @@ -405,7 +405,7 @@ def _classify(self, treenode, x):
x,
treenode.splitter[0][branches[i]],
metric=measure,
kwargs=treenode.splitter[1][measure],
**treenode.splitter[1][measure],
)
if dist < min_dist:
min_dist = dist
Expand Down
4 changes: 2 additions & 2 deletions aeon/clustering/tests/test_elastic_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from aeon.clustering import ElasticSOM
from aeon.distances import dtw_distance, msm_alignment_path
from aeon.distances._distance import DISTANCES
from aeon.distances._distance import ELASTIC_DISTANCES
from aeon.testing.data_generation import make_example_3d_numpy


Expand Down Expand Up @@ -245,7 +245,7 @@ def custom_neighborhood_function(neuron_position, c, sigma):
clst.fit(X)


@pytest.mark.parametrize("dist", DISTANCES)
@pytest.mark.parametrize("dist", ELASTIC_DISTANCES)
def test_elastic_som_distances(dist):
"""Test ElasticSOM distances."""
if "distance" not in dist:
Expand Down
42 changes: 27 additions & 15 deletions aeon/distances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
"shape_dtw_pairwise_distance",
"sbd_distance",
"sbd_pairwise_distance",
"mpdist",
"mpdist_pairwise_distance",
"paa_sax_mindist",
"sax_mindist",
"sfa_mindist",
"dft_sfa_mindist",
"mp_distance",
"mp_pairwise_distance",
"mindist_paa_sax_distance",
"mindist_sax_distance",
"mindist_sfa_distance",
"mindist_dft_sfa_distance",
"shift_scale_invariant_distance",
"shift_scale_invariant_pairwise_distance",
"shift_scale_invariant_best_shift",
Expand All @@ -80,7 +80,6 @@
"soft_dtw_cost_matrix",
]

from aeon.distances._dft_sfa_mindist import dft_sfa_mindist
from aeon.distances._distance import (
alignment_path,
cost_matrix,
Expand All @@ -92,20 +91,13 @@
get_pairwise_distance_function,
pairwise_distance,
)
from aeon.distances._euclidean import euclidean_distance, euclidean_pairwise_distance
from aeon.distances._manhattan import manhattan_distance, manhattan_pairwise_distance
from aeon.distances._minkowski import minkowski_distance, minkowski_pairwise_distance
from aeon.distances._mpdist import mpdist, mpdist_pairwise_distance
from aeon.distances._paa_sax_mindist import paa_sax_mindist
from aeon.distances._sax_mindist import sax_mindist
from aeon.distances._mpdist import mp_distance, mp_pairwise_distance
from aeon.distances._sbd import sbd_distance, sbd_pairwise_distance
from aeon.distances._sfa_mindist import sfa_mindist
from aeon.distances._shift_scale_invariant import (
shift_scale_invariant_best_shift,
shift_scale_invariant_distance,
shift_scale_invariant_pairwise_distance,
)
from aeon.distances._squared import squared_distance, squared_pairwise_distance
from aeon.distances.elastic import (
adtw_alignment_path,
adtw_cost_matrix,
Expand Down Expand Up @@ -157,3 +149,23 @@
wdtw_distance,
wdtw_pairwise_distance,
)
from aeon.distances.mindist._dft_sfa import mindist_dft_sfa_distance
from aeon.distances.mindist._paa_sax import mindist_paa_sax_distance
from aeon.distances.mindist._sax import mindist_sax_distance
from aeon.distances.mindist._sfa import mindist_sfa_distance
from aeon.distances.pointwise._euclidean import (
euclidean_distance,
euclidean_pairwise_distance,
)
from aeon.distances.pointwise._manhattan import (
manhattan_distance,
manhattan_pairwise_distance,
)
from aeon.distances.pointwise._minkowski import (
minkowski_distance,
minkowski_pairwise_distance,
)
from aeon.distances.pointwise._squared import (
squared_distance,
squared_pairwise_distance,
)
Loading