[NumPy-Tickets] [NumPy] #1535: numpy.random.permutations fails for non-integer arguments
NumPy Trac
numpy-tickets@scipy....
Mon Jul 5 05:13:25 CDT 2010
#1535: numpy.random.permutations fails for non-integer arguments
------------------------------------+---------------------------------------
Reporter: robince | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.random | Version:
Keywords: permutation long 64bit |
------------------------------------+---------------------------------------
When calling numpy.random.permutation with non-integer arguments it fails
with a cryptic error message:
{{{
In [49]: np.random.permutation(12)
Out[49]: array([10, 9, 4, 7, 3, 8, 0, 6, 5, 1, 11, 2])
In [50]: np.random.permutation(12.0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
D:\robin\pyentropy-0.4.0\<ipython console> in <module>()
C:\Python26\lib\site-packages\numpy\random\mtrand.pyd in
mtrand.RandomState.permutation (build\scons\numpy\random\mtrand
\mtrand.c:18669)()
C:\Python26\lib\site-packages\numpy\random\mtrand.pyd in
mtrand.RandomState.shuffle (build\scons\numpy\random\mtrand\mtr
and.c:18261)()
TypeError: len() of unsized object
> d:\robin\pyentropy-0.4.0\mtrand.pyx(4174)mtrand.RandomState.shuffle
(build\scons\numpy\random\mtrand\mtrand.c:18261)()
}}}
This also happens with long arguments, and so
np.random.permutation(X.shape[0]) where X is an array fails on 64 bit
windows (where shape is a tuple of longs).
It would be great if it could cast to integer or at least raise a proper
error for non-integer types.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1535>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list