[SciPy-Dev] ENH: added args and kwargs to Xdist

alebarde at gmail.com alebarde at gmail.com
Thu Jan 19 15:40:46 EST 2017


Hi all,

the current implementations of pdist and cdist takes as keyword arguments
some extra parameters for a few specific metrics. At the same time, they do
not allow for others args/kwargs that may be needed by a new user-defined
metric.
Plus, in 0.19 it is possible to call:

pdist([[1,2,3]], metric='euclidean', V=[1,2,3], w=[1,2,3])
pdist([[1,2,3]], metric='seuclidean', VI=[1,2,3])

IMHO this is quite strange behaviour since I would have expected an error.
In particular, in the second case, the error would also probably help
debugging the code since it may be a copy-and-paste typo (seuclidean takes
V as kwarg, while mahalanobis requires VI)

I have opened a PR (https://github.com/scipy/scipy/pull/6974) that
introduces support for *args and **kwargs that gets passed on to the
selected metric. The new functions should not break any existing code with
the exception of the previous example.
However, if needed, I can try to catch those cases, and for now just raise
a deprecate warning.

what do you think?

Alessandro

-- 
--------------------------------------------------------------------------
NOTICE: Dlgs 196/2003 this e-mail and any attachments thereto may contain
confidential information and are intended for the sole use of the
recipient(s) named above. If you are not the intended recipient of this
message you are hereby notified that any dissemination or copying of this
message is strictly prohibited. If you have received this e-mail in error,
please notify the sender either by telephone or by e-mail and delete the
material from any computer. Thank you.
--------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170119/244f273b/attachment.html>


More information about the SciPy-Dev mailing list