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

Keith Goodman kwgoodman at gmail.com
Thu Jan 18 12:20:00 EST 2007


On 1/18/07, Emanuele Olivetti <emanuele at relativita.com> wrote:
> 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.

I don't think that bug is particular to int32. For example:

>> numpy.random.permutation(1.2)
TypeError: len() of unsized object



More information about the NumPy-Discussion mailing list