@@ -152,7 +152,8 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
152152 - x_a and x_b are the samples
153153 - a and b are the sample weights
154154
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`.
156157
157158 Uses the algorithm detailed in [1]_
158159
@@ -167,9 +168,8 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
167168 b : (nt,) ndarray, float64, optional
168169 Target histogram (default is uniform weight)
169170 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'`.
173173 p: float, optional (default=1.0)
174174 The p-norm to apply for if metric='minkowski'
175175 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,
234234 "emd_1d should only be used with monodimensional data"
235235 assert (x_b .ndim == 1 or x_b .ndim == 2 and x_b .shape [1 ] == 1 ), \
236236 "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+ )
237243
238244 # if empty array given then use uniform distributions
239245 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,
300306 - x_a and x_b are the samples
301307 - a and b are the sample weights
302308
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`.
304311
305312 Uses the algorithm detailed in [1]_
306313
@@ -315,10 +322,8 @@ def emd2_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
315322 b : (nt,) ndarray, float64, optional
316323 Target histogram (default is uniform weight)
317324 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'`.
322327 p: float, optional (default=1.0)
323328 The p-norm to apply for if metric='minkowski'
324329 dense: boolean, optional (default=True)
0 commit comments