<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 09/05/2013 01:29 PM, Warren
Weckesser wrote:<br>
</div>
<blockquote
cite="mid:CAGzF1ufXz15sBZBjOyyDSdvOr6BavfMkCpZrVR6YnTttOgjMPg@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Sep 5, 2013 at 2:11 PM,
Fernando Perez <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:fperez.net@gmail.com" target="_blank">fperez.net@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I just ran into this rather weird behavior:<br>
<br>
<a moz-do-not-send="true"
href="http://nbviewer.ipython.org/6453869"
target="_blank">http://nbviewer.ipython.org/6453869</a><br>
<br>
In summary, as far as I can tell, shuffle is misbehaving
when acting<br>
on arrays that have structured dtypes. I've seen the
problem on 1.7.1<br>
(official on ubuntu 13.04) as well as master as of a few
minutes ago.<br>
<br>
Is this my misuse? It really looks like a bug to me...<br>
<br>
</blockquote>
<div><br>
<br>
</div>
<div>Definitely a bug:<br>
<br>
<span style="font-family:courier new,monospace">In [1]:
np.__version__<br>
Out[1]: '1.9.0.dev-573b3b0'<br>
<br>
In [2]: z = np.array([(0,),(1,),(2,),(3,),(4,)],
dtype=[('a',int)])<br>
<br>
In [3]: z<br>
Out[3]: <br>
array([(0,), (1,), (2,), (3,), (4,)], <br>
dtype=[('a', '<i8')])<br>
<br>
In [4]: shuffle(z)<br>
<br>
In [5]: z<br>
Out[5]: <br>
array([(0,), (1,), (2,), (0,), (0,)], <br>
dtype=[('a', '<i8')])</span><br>
<br>
<br>
<br>
</div>
<div>Nothing in the docstring suggests that it shouldn't
work for structured dtypes.<br>
<br>
Warren<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
Looks to stemming from the fact that elements of records arrays
cannot be swapped:<br>
<br>
In [1]: import numpy as np<br>
<br>
In [2]: x = np.zeros(5, dtype=[('n', 'S1'), ('i', int)])<br>
<br>
In [3]: x['i'] = range(5)<br>
<br>
In [4]: print x<br>
[('', 0) ('', 1) ('', 2) ('', 3) ('', 4)]<br>
<br>
In [5]: x[0], x[1] = x[1], x[0]<br>
<br>
In [6]: print x<br>
[('', 1) ('', 1) ('', 2) ('', 3) ('', 4)]<br>
<br>
This is with numpy 1.7.1<br>
<br>
Cheers,<br>
<br>
- Jonathan Helmus<br>
<br>
<br>
<blockquote
cite="mid:CAGzF1ufXz15sBZBjOyyDSdvOr6BavfMkCpZrVR6YnTttOgjMPg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div><br>
<br>
</div>
<div><br>
<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
Cheers,<br>
<br>
f<br>
<span class=""><font color="#888888"><br>
--<br>
Fernando Perez (@fperez_org; <a
moz-do-not-send="true" href="http://fperez.org"
target="_blank">http://fperez.org</a>)<br>
fperez.net-at-gmail: mailing lists only (I ignore this
when swamped!)<br>
fernando.perez-at-berkeley: contact me here for any
direct mail<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a moz-do-not-send="true"
href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a moz-do-not-send="true"
href="http://mail.scipy.org/mailman/listinfo/numpy-discussion"
target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</font></span></blockquote>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
</blockquote>
<br>
</body>
</html>