[NumPy-Tickets] [NumPy] #1546: function prod fails over arrays without warm

NumPy Trac numpy-tickets@scipy....
Thu Jul 15 06:24:18 CDT 2010


#1546: function prod fails over arrays without warm
---------------------------+------------------------------------------------
 Reporter:  mmarquez       |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:  2.0.0   
Component:  Other          |     Version:          
 Keywords:  function prod  |  
---------------------------+------------------------------------------------
 I'm a begginer using python. As a very simply exercise I was defining the
 fact function, but I had a very bad surprise. The output of

 {{{

 import numpy
 def fact(n):
     return numpy.prod(range(2,n+1))
 for i in range(2,50,5):
     print "Fact of i %d is %d"%(i,fact(i))

 }}}

 is

 {{{
 Fact of i 2 is 2
 Fact of i 7 is 5040
 Fact of i 12 is 479001600
 Fact of i 17 is -288522240
 Fact of i 22 is -522715136
 Fact of i 27 is 1484783616
 Fact of i 32 is -2147483648
 Fact of i 37 is 0
 Fact of i 42 is 0
 Fact of i 47 is 0
 }}}


 which is obviously''' wrong'''. But even more, this happen '''without any
 warning or error messages'''.

 This is wrong even if the computations are made using modular arithmetic
 as claimed by the help.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1546>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list