[Numpy-discussion] A bug in numpy.random.shuffle?
Bradley M. Froehle
brad.froehle at gmail.com
Thu Sep 5 14:30:25 EDT 2013
Looks like a bug. FWIW, NumPy 1.6.1 on Scientific Linux 6.4 does not
suffer from this malady.
-Brad
$ python
Python 2.6.6 (r266:84292, Feb 21 2013, 19:26:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import numpy as np
>>> from numpy.random import shuffle
>>>
>>> print 'Numpy version:', np.__version__
Numpy version: 1.6.2
>>>
>>> a = np.arange(5)
>>> for i in range(5):
... print a
... shuffle(a)
...
[0 1 2 3 4]
[2 1 0 4 3]
[0 4 3 1 2]
[4 1 0 2 3]
[2 0 4 3 1]
>>>
>>> b = np.zeros(5, dtype=[('n', 'S1'), ('i', int)])
>>> b['i'] = range(5)
>>> print b
[('', 0) ('', 1) ('', 2) ('', 3) ('', 4)]
>>> print b.dtype
[('n', '|S1'), ('i', '<i8')]
>>> for i in range(5):
... print b
... shuffle(b)
...
[('', 0) ('', 1) ('', 2) ('', 3) ('', 4)]
[('', 0) ('', 2) ('', 4) ('', 1) ('', 3)]
[('', 2) ('', 0) ('', 4) ('', 1) ('', 3)]
[('', 2) ('', 1) ('', 3) ('', 4) ('', 0)]
[('', 0) ('', 1) ('', 2) ('', 4) ('', 3)]
On Thu, Sep 5, 2013 at 11:11 AM, Fernando Perez <fperez.net at gmail.com> wrote:
> Hi all,
>
> I just ran into this rather weird behavior:
>
> http://nbviewer.ipython.org/6453869
>
> In summary, as far as I can tell, shuffle is misbehaving when acting
> on arrays that have structured dtypes. I've seen the problem on 1.7.1
> (official on ubuntu 13.04) as well as master as of a few minutes ago.
>
> Is this my misuse? It really looks like a bug to me...
>
> Cheers,
>
> f
>
> --
> Fernando Perez (@fperez_org; http://fperez.org)
> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
> fernando.perez-at-berkeley: contact me here for any direct mail
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list