28
28
29
29
30
30
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
32
32
):
33
33
"""
34
34
Validate the distance result by comparing it with the expected result.
@@ -57,12 +57,13 @@ def _validate_distance_result(
57
57
assert isinstance (dist_result_to_self , float )
58
58
59
59
# 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 :
61
61
_validate_distance_result (
62
62
original_y ,
63
63
original_x ,
64
64
name ,
65
65
distance ,
66
+ symmetric ,
66
67
expected_result ,
67
68
check_xy_permuted = False ,
68
69
)
@@ -82,6 +83,7 @@ def test_distances(dist):
82
83
make_example_1d_numpy (10 , random_state = 2 ),
83
84
dist ["name" ],
84
85
dist ["distance" ],
86
+ dist ["symmetric" ],
85
87
_expected_distance_results [dist ["name" ]][0 ],
86
88
)
87
89
@@ -91,6 +93,7 @@ def test_distances(dist):
91
93
make_example_2d_numpy_series (10 , 1 , random_state = 2 ),
92
94
dist ["name" ],
93
95
dist ["distance" ],
96
+ dist ["symmetric" ],
94
97
_expected_distance_results [dist ["name" ]][0 ],
95
98
)
96
99
@@ -100,6 +103,7 @@ def test_distances(dist):
100
103
make_example_2d_numpy_series (10 , 1 , random_state = 2 ),
101
104
dist ["name" ],
102
105
dist ["distance" ],
106
+ dist ["symmetric" ],
103
107
_expected_distance_results [dist ["name" ]][1 ],
104
108
)
105
109
@@ -111,6 +115,7 @@ def test_distances(dist):
111
115
make_example_1d_numpy (10 , random_state = 2 ),
112
116
dist ["name" ],
113
117
dist ["distance" ],
118
+ dist ["symmetric" ],
114
119
_expected_distance_results [dist ["name" ]][2 ],
115
120
)
116
121
@@ -120,6 +125,7 @@ def test_distances(dist):
120
125
make_example_2d_numpy_series (10 , 1 , random_state = 2 ),
121
126
dist ["name" ],
122
127
dist ["distance" ],
128
+ dist ["symmetric" ],
123
129
_expected_distance_results [dist ["name" ]][2 ],
124
130
)
125
131
@@ -129,6 +135,7 @@ def test_distances(dist):
129
135
make_example_2d_numpy_series (10 , 10 , random_state = 2 ),
130
136
dist ["name" ],
131
137
dist ["distance" ],
138
+ dist ["symmetric" ],
132
139
_expected_distance_results [dist ["name" ]][3 ],
133
140
)
134
141
@@ -140,6 +147,7 @@ def test_distances(dist):
140
147
np .array ([15.0 ]),
141
148
dist ["name" ],
142
149
dist ["distance" ],
150
+ dist ["symmetric" ],
143
151
_expected_distance_results [dist ["name" ]][4 ],
144
152
)
145
153
@@ -149,6 +157,7 @@ def test_distances(dist):
149
157
np .array ([[15.0 ]]),
150
158
dist ["name" ],
151
159
dist ["distance" ],
160
+ dist ["symmetric" ],
152
161
_expected_distance_results [dist ["name" ]][4 ],
153
162
)
154
163
0 commit comments