[NumPy-Tickets] [NumPy] #1413: np.random.binomial() fails with int64 'n' argument on x86/32-bit

NumPy Trac numpy-tickets@scipy....
Fri Feb 26 03:44:16 CST 2010


#1413: np.random.binomial() fails with int64 'n' argument on x86/32-bit
-----------------------------------------------------+----------------------
 Reporter:  david.warde-farley                       |       Owner:  somebody
     Type:  defect                                   |      Status:  new     
 Priority:  normal                                   |   Milestone:          
Component:  numpy.random                             |     Version:          
 Keywords:  random mtrand binomial int64 mtrand.pyx  |  
-----------------------------------------------------+----------------------

Comment(by pv):

 I think this is a casting issue: the function is defined to accept only
 int32 (= NPY_LONG on 32-bit), but int64 (= NPY_LONG_LONG) is for some
 reason not automatically cast to the smaller integer.

 In other contexts, Numpy does downcast automatically without warnings,
 {{{
 >>> x = numpy.array([1,2,3,], dtype='int32')
 >>> x[:] = numpy.asarray([212312312333,3,4], dtype='int64')
 >>> x
 array([1858914829,          3,          4])
 }}}
 so probably it should do it also here.

 Another related issue is that on 64-bit, if you define ufunc to accept
 only NPY_INT, it won't accept NPY_LONG but fails instead with a similar
 error.

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


More information about the NumPy-Tickets mailing list