@@ -152,7 +152,8 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
152
152
- x_a and x_b are the samples
153
153
- a and b are the sample weights
154
154
155
- When 'minkowski' is used as a metric, :math:`d(x, y) = |x - y|^p`.
155
+ This implementation only supports metrics
156
+ of the form :math:`d(x, y) = |x - y|^p`.
156
157
157
158
Uses the algorithm detailed in [1]_
158
159
@@ -167,9 +168,8 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
167
168
b : (nt,) ndarray, float64, optional
168
169
Target histogram (default is uniform weight)
169
170
metric: str, optional (default='sqeuclidean')
170
- Metric to be used. Only strings listed in :func:`ot.dist` are accepted.
171
- Due to implementation details, this function runs faster when
172
- `'sqeuclidean'`, `'cityblock'`, or `'euclidean'` metrics are used.
171
+ Metric to be used. Only works with either of the strings
172
+ `'sqeuclidean'`, `'minkowski'`, `'cityblock'`, or `'euclidean'`.
173
173
p: float, optional (default=1.0)
174
174
The p-norm to apply for if metric='minkowski'
175
175
dense: boolean, optional (default=True)
@@ -234,6 +234,12 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
234
234
"emd_1d should only be used with monodimensional data"
235
235
assert (x_b .ndim == 1 or x_b .ndim == 2 and x_b .shape [1 ] == 1 ), \
236
236
"emd_1d should only be used with monodimensional data"
237
+ if metric not in ['sqeuclidean' , 'minkowski' , 'cityblock' , 'euclidean' ]:
238
+ raise ValueError (
239
+ "Solver for EMD in 1d only supports metrics " +
240
+ "from the following list: " +
241
+ "`['sqeuclidean', 'minkowski', 'cityblock', 'euclidean']`"
242
+ )
237
243
238
244
# if empty array given then use uniform distributions
239
245
if a is None or a .ndim == 0 or len (a ) == 0 :
@@ -300,7 +306,8 @@ def emd2_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
300
306
- x_a and x_b are the samples
301
307
- a and b are the sample weights
302
308
303
- When 'minkowski' is used as a metric, :math:`d(x, y) = |x - y|^p`.
309
+ This implementation only supports metrics
310
+ of the form :math:`d(x, y) = |x - y|^p`.
304
311
305
312
Uses the algorithm detailed in [1]_
306
313
@@ -315,10 +322,8 @@ def emd2_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
315
322
b : (nt,) ndarray, float64, optional
316
323
Target histogram (default is uniform weight)
317
324
metric: str, optional (default='sqeuclidean')
318
- Metric to be used. Only strings listed in :func:`ot.dist` are accepted.
319
- Due to implementation details, this function runs faster when
320
- `'sqeuclidean'`, `'minkowski'`, `'cityblock'`, or `'euclidean'` metrics
321
- are used.
325
+ Metric to be used. Only works with either of the strings
326
+ `'sqeuclidean'`, `'minkowski'`, `'cityblock'`, or `'euclidean'`.
322
327
p: float, optional (default=1.0)
323
328
The p-norm to apply for if metric='minkowski'
324
329
dense: boolean, optional (default=True)
0 commit comments