[Numpy-discussion] numpy.random.permutation bug?

Emanuele Olivetti emanuele at relativita.com
Thu Jan 18 12:09:54 EST 2007


Look at this:

----------bug.py-------
import numpy
a=numpy.array([1,2])
b=a.sum()
print type(b)
c=numpy.random.permutation(b)
-----------------------

If I run it (Python 2.5, numpy 1.0.1 on a Linux box) I get:
-----------
#> python /tmp/bug.py
<type 'numpy.int32'>
Traceback (most recent call last):
  File "/tmp/bug.py", line 5, in <module>
    c=numpy.random.permutation(b)
  File "mtrand.pyx", line 1227, in mtrand.RandomState.permutation
  File "mtrand.pyx", line 1211, in mtrand.RandomState.shuffle
TypeError: len() of unsized object
-----------

permutation() likes 'int' and dislikes 'numpy.int32' integers :(
Seems a bug.

HTH,

Emanuele





More information about the NumPy-Discussion mailing list