[NumPy-Tickets] [NumPy] #1396: Numpy product of zero-length array returns 1.0

NumPy Trac numpy-tickets@scipy....
Sun Mar 21 23:07:11 CDT 2010


#1396: Numpy product of zero-length array returns 1.0
----------------------------------------+-----------------------------------
 Reporter:  xdylanm                     |       Owner:  somebody      
     Type:  enhancement                 |      Status:  needs_decision
 Priority:  normal                      |   Milestone:                
Component:  numpy.core                  |     Version:  1.3.0         
 Keywords:  product, prod, zero-length  |  
----------------------------------------+-----------------------------------

Comment(by warren.weckesser):

 I'll add my support for leaving the behavior unchanged.  Consider that
 k**n is the same as prod([k]*n), and k**0 is 1.  More explicitly, the
 following sequence might help make the value 1 in the last step seem more
 natural:
 {{{
 In [16]: 2.0**3, np.prod([2.0, 2.0, 2.0])
 Out[16]: (8.0, 8.0)

 In [17]: 2.0**2, np.prod([2.0, 2.0])
 Out[17]: (4.0, 4.0)

 In [18]: 2.0**1, np.prod([2.0])
 Out[18]: (2.0, 2.0)

 In [19]: 2.0**0, np.prod([])
 Out[19]: (1.0, 1.0)
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1396#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list