Skip to content

Commit 5a759d8

Browse files
authored
[ENH] Adds support for distances that are asymmetric but supports unequal length (aeon-toolkit#2613)
* Adds support for distances that are asymmetric but supports unequal length * Added name to contributors
1 parent db83bfc commit 5a759d8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,15 @@
26742674
"contributions": [
26752675
"doc"
26762676
]
2677+
},
2678+
{
2679+
"login": "tanishy7777",
2680+
"name": "Tanish Yelgoe",
2681+
"avatar_url": "https://avatars.githubusercontent.com/u/143334319?v=4",
2682+
"profile": "https://www.tanishyelgoe.tech/",
2683+
"contributions": [
2684+
"code"
2685+
]
26772686
}
26782687
],
26792688
"commitType": "docs"

aeon/distances/tests/test_distances.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def _validate_distance_result(
31-
x, y, name, distance, expected_result=10, check_xy_permuted=True
31+
x, y, name, distance, symmetric, expected_result=10, check_xy_permuted=True
3232
):
3333
"""
3434
Validate the distance result by comparing it with the expected result.
@@ -57,12 +57,13 @@ def _validate_distance_result(
5757
assert isinstance(dist_result_to_self, float)
5858

5959
# If unequal length swap where x and y are to ensure it works both ways around
60-
if original_x.shape[-1] != original_y.shape[-1] and check_xy_permuted:
60+
if symmetric and original_x.shape[-1] != original_y.shape[-1] and check_xy_permuted:
6161
_validate_distance_result(
6262
original_y,
6363
original_x,
6464
name,
6565
distance,
66+
symmetric,
6667
expected_result,
6768
check_xy_permuted=False,
6869
)
@@ -82,6 +83,7 @@ def test_distances(dist):
8283
make_example_1d_numpy(10, random_state=2),
8384
dist["name"],
8485
dist["distance"],
86+
dist["symmetric"],
8587
_expected_distance_results[dist["name"]][0],
8688
)
8789

@@ -91,6 +93,7 @@ def test_distances(dist):
9193
make_example_2d_numpy_series(10, 1, random_state=2),
9294
dist["name"],
9395
dist["distance"],
96+
dist["symmetric"],
9497
_expected_distance_results[dist["name"]][0],
9598
)
9699

@@ -100,6 +103,7 @@ def test_distances(dist):
100103
make_example_2d_numpy_series(10, 1, random_state=2),
101104
dist["name"],
102105
dist["distance"],
106+
dist["symmetric"],
103107
_expected_distance_results[dist["name"]][1],
104108
)
105109

@@ -111,6 +115,7 @@ def test_distances(dist):
111115
make_example_1d_numpy(10, random_state=2),
112116
dist["name"],
113117
dist["distance"],
118+
dist["symmetric"],
114119
_expected_distance_results[dist["name"]][2],
115120
)
116121

@@ -120,6 +125,7 @@ def test_distances(dist):
120125
make_example_2d_numpy_series(10, 1, random_state=2),
121126
dist["name"],
122127
dist["distance"],
128+
dist["symmetric"],
123129
_expected_distance_results[dist["name"]][2],
124130
)
125131

@@ -129,6 +135,7 @@ def test_distances(dist):
129135
make_example_2d_numpy_series(10, 10, random_state=2),
130136
dist["name"],
131137
dist["distance"],
138+
dist["symmetric"],
132139
_expected_distance_results[dist["name"]][3],
133140
)
134141

@@ -140,6 +147,7 @@ def test_distances(dist):
140147
np.array([15.0]),
141148
dist["name"],
142149
dist["distance"],
150+
dist["symmetric"],
143151
_expected_distance_results[dist["name"]][4],
144152
)
145153

@@ -149,6 +157,7 @@ def test_distances(dist):
149157
np.array([[15.0]]),
150158
dist["name"],
151159
dist["distance"],
160+
dist["symmetric"],
152161
_expected_distance_results[dist["name"]][4],
153162
)
154163

0 commit comments

Comments
 (0)