[SciPy-Dev] Proposal to deprecate squeeze on distance metric inputs

Peter Bell PeterBell10 at live.co.uk
Sun Apr 4 17:03:01 EDT 2021


Currently, all the metrics in scipy.spatial.distance​ call _validate_vector which internally does

input = np.atleast_1d(input.squeeze())

This means the input can have any number of extra length-1 dimensions which are ignored and not propagated to the output.  Shapes that shouldn't be compatible (e.g. (1, 3) and (3, 1) array) also match up as if they were 1d, instead of broadcasting like normal NumPy operations.

In order to extend the distance metrics with n-dimensional array support, we either break broadcasting or remove this behavior.
So, in PR #13774<https://github.com/scipy/scipy/pull/13774> I'm proposing to deprecate the squeeze and require the input actually be 1-dimensional.

-Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-dev/attachments/20210404/9f915957/attachment.html>


More information about the SciPy-Dev mailing list