-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.ndimage
Milestone
Description
Describe your issue.
Getting FutureWarning
when using distance_transform_cdt
with a metric that is a numpy array
FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
In here
scipy/scipy/ndimage/_morphology.py
Line 2075 in 5057eff
if metric in ['taxicab', 'cityblock', 'manhattan']: |
we need to replace
if metric in ['taxicab', 'cityblock', 'manhattan']:
rank = input.ndima
metric = generate_binary_structure(rank, 1)
elif metric == 'chessboard':
rank = input.ndim
metric = generate_binary_structure(rank, rank)
by
if isintance(metric,str) and metric in ['taxicab', 'cityblock', 'manhattan']:
rank = input.ndima
metric = generate_binary_structure(rank, 1)
elif isintance(metric,str) and metric == 'chessboard':
rank = input.ndim
metric = generate_binary_structure(rank, rank)
Reproducing Code Example
from scipy impoirt ndimage
import numpy as np
ndimage.distance_transform_cdt(np.zeros((5,5), dtype=bool), metric=np.ones((3,3), dtype=bool))
Error message
<string>:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
SciPy/NumPy/Python version information
1.9.3
Metadata
Metadata
Assignees
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.ndimage