You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling ot.dist with metric set to hamming an AttributeError is thrown from within scipy.cdist
To Reproduce
(tested using python 3.10, ot version 0.8.2 and scipy version 1.9.1 as well as 1.8.0):
import ot
import numpy as np
x = np.random.randint(0, 2, 20).reshape(4, 5)
y = np.random.randint(0, 2, 20).reshape(4, 5)
ot.dist(x, y, metric="hamming")
Environment
OS: Ubuntu 22.04
Python version: 3.10
Install: conda
Traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "miniconda3/envs/mtda/lib/python3.10/site-packages/ot/utils.py", line 237, in dist
return cdist(x1, x2, metric=metric, w=w)
File "miniconda3/envs/mtda/lib/python3.10/site-packages/scipy/spatial/distance.py", line 2929, in cdist
return cdist_fn(XA, XB, out=out, **kwargs)
File "miniconda3/envs/mtda/lib/python3.10/site-packages/scipy/spatial/distance.py", line 1673, in __call__
XA, XB, typ, kwargs = _validate_cdist_input(
File "miniconda3/envs/mtda/lib/python3.10/site-packages/scipy/spatial/distance.py", line 205, in _validate_cdist_input
kwargs = _validate_kwargs((XA, XB), mA + mB, n, **kwargs)
File "miniconda3/envs/mtda/lib/python3.10/site-packages/scipy/spatial/distance.py", line 225, in _validate_hamming_kwargs
if w.ndim != 1 or w.shape[0] != n:
AttributeError: 'NoneType' object has no attribute 'ndim'
The same error is raised when scipy.cdist is called with w=None
from scipy.spatial.distance import cdist
cdist(x, y, metric="hamming", w=None)
Bug Description
When calling
ot.dist
with metric set to hamming an AttributeError is thrown from withinscipy.cdist
To Reproduce
(tested using python 3.10, ot version 0.8.2 and scipy version 1.9.1 as well as 1.8.0):
Environment
conda
Traceback:
The same error is raised when scipy.cdist is called with
w=None
Hence it seems like not passing
w
herePOT/ot/utils.py
Line 237 in 951209a
when
w
isNone
should resolve the bug.The text was updated successfully, but these errors were encountered: