[Numpy-discussion] A bug in numpy.random.shuffle?

Warren Weckesser warren.weckesser at gmail.com
Thu Sep 5 14:29:09 EDT 2013


On Thu, Sep 5, 2013 at 2:11 PM, 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...
>
>

Definitely a bug:

In [1]: np.__version__
Out[1]: '1.9.0.dev-573b3b0'

In [2]: z = np.array([(0,),(1,),(2,),(3,),(4,)], dtype=[('a',int)])

In [3]: z
Out[3]:
array([(0,), (1,), (2,), (3,), (4,)],
      dtype=[('a', '<i8')])

In [4]: shuffle(z)

In [5]: z
Out[5]:
array([(0,), (1,), (2,), (0,), (0,)],
      dtype=[('a', '<i8')])



Nothing in the docstring suggests that it shouldn't work for structured
dtypes.

Warren




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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130905/7f0d606e/attachment.html>


More information about the NumPy-Discussion mailing list