[NumPy-Tickets] [NumPy] #1396: Numpy product of zero-length array returns 1.0
NumPy Trac
numpy-tickets@scipy....
Wed Feb 10 09:28:32 CST 2010
#1396: Numpy product of zero-length array returns 1.0
----------------------------------------+-----------------------------------
Reporter: xdylanm | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: numpy.core | Version: 1.3.0
Keywords: product, prod, zero-length |
----------------------------------------+-----------------------------------
{{{
>>> numpy.prod([])
1.0
}}}
or
{{{
>>> a = numpy.array([])
>>> numpy.prod(a)
1.0
}}}
This behaviour seems counterintuitive. Either an error should be raised
(nothing to multiply) or it should return zero.
Workaround: test the length of the array before passing to prod.
numpy version 1.3.0
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1396>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list