Re: [Numpy-discussion] problem w 32bit binomial?
On 25-Feb-10, at 5:59 PM, James Bergstra wrote: > In case this hasn't been solved in more recent numpy... > > I've tried the following lines on two installations of numpy 1.3 > with python 2.6 > > numpy.random.binomial(n=numpy.asarray([2,3,4], dtype='int64'), > p=numpy.asarray([.1, .2, .3], dtype='float64')) > > A 64bit computer gives an output of array length 3. > A 32bit computer gives an error: > > TypeError: array cannot be safely cast to required type > > If I change the int64 cast to an int32 cast then it works on both > machines. Alright, filed as a ticket at http://projects.scipy.org/numpy/ticket/1413 David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] problem w 32bit binomial?
Hey James, On 25-Feb-10, at 5:59 PM, James Bergstra wrote: > In case this hasn't been solved in more recent numpy... > > I've tried the following lines on two installations of numpy 1.3 > with python 2.6 > > numpy.random.binomial(n=numpy.asarray([2,3,4], dtype='int64'), > p=numpy.asarray([.1, .2, .3], dtype='float64')) > > A 64bit computer gives an output of array length 3. > A 32bit computer gives an error: > > TypeError: array cannot be safely cast to required type It seems to be not only 32-bit specific but x86-specific. On a ppc machine, 32-bit mode: d...@morrislab:~$ python-32 Python 2.6.4 (r264:75706, Feb 16 2010, 21:03:46) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.__version__ '1.3.0' >>> numpy.random.binomial(n=numpy.asarray([2,3,4], dtype='int64'), p=numpy.asarray([.1,.2,.3], dtype='float64')) array([1, 1, 2]) But I can confirm the bug on OS X/Intel 32-bit, and Linux x86-32 (both 1.3.0 and most recent svn trunk), as well as its absence on Linux x86-64. The problem seems to be with this line in mtrand.pyx, line 3306 in the trunk: on = PyArray_FROM_OTF(n, NPY_LONG, NPY_ALIGNED) I recall there being some consistency problems with NPY_LONG across architectures. I thought it was only an issue for Python 2.4, though... Perhaps Chuck or David C. know what's going on. David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] problem w 32bit binomial?
In case this hasn't been solved in more recent numpy... I've tried the following lines on two installations of numpy 1.3 with python 2.6 numpy.random.binomial(n=numpy.asarray([2,3,4], dtype='int64'), p=numpy.asarray([.1, .2, .3], dtype='float64')) A 64bit computer gives an output of array length 3. A 32bit computer gives an error: TypeError: array cannot be safely cast to required type If I change the int64 cast to an int32 cast then it works on both machines. Thanks, James -- http://www-etud.iro.umontreal.ca/~bergstrj -- http://www-etud.iro.umontreal.ca/~bergstrj ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion