[Scipy-tickets] [SciPy] #1328: scipy.spatial.distance.sqeuclidean broken: Invalid results
SciPy Trac
scipy-tickets@scipy....
Sun Jun 12 09:49:22 CDT 2011
#1328: scipy.spatial.distance.sqeuclidean broken: Invalid results
------------------------------------------------------------------------------------+
Reporter: stefan_r | Owner: peridot
Type: defect | Status: needs_review
Priority: normal | Milestone: 0.10.0
Component: scipy.spatial | Version: 0.8.0
Keywords: squared euclidean distance,distance,scipy.spatial.distance.sqeuclidean |
------------------------------------------------------------------------------------+
Changes (by rgommers):
* priority: high => normal
* milestone: 0.9.0 => 0.10.0
Comment:
This is not a bug. The function calculates the distance between two
vectors, which means the inputs should be 1-D. This is the case for many
distance functions in spatial.distance. It doesn't make sense to me to
allow an array of vectors (2-D) and apply broadcasting, unless that is
done for all distance metrics. Otherwise the interface just becomes less
consistent.
I propose to flatten the input if only one dimension is of size >1, and
calculate the result as if it was a 1-D input. If the input has more
dimensions of size >1 an exception should be raised.
This already works correctly:
{{{
x = np.random.random(100)
y = np.random.random(100)
d1 = euclidean(x, y)
d2 = sqeuclidean(x, y)
assert_array_almost_equal(d1**2, d2, decimal=14)
}}}
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1328#comment:7>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list