[Numpy-discussion] Documentation for dtypes with named fields
Sam Tygier
Sam.Tygier@hep.manchester.ac...
Tue Mar 16 11:04:14 CDT 2010
On Tue, Mar 16, 2010 at 11:34 AM, Skipper Seabold <jsseabold@gmail.com> wrote:
>> so i always get the vales back in the original order. is the by design, or a bug?
>>
>
> I've been bitten by this before too and asked the same question with
> no response. I think it's just a limitation of the design of
> structured arrays.
i had a hunt for the code. and it seems easy to fix.
its in numpy/core/_internal.py:301
--- numpy/core/_internal.py 2010-03-16 16:01:28.000000000 +0000
+++ numpy/core/_internal.py.old 2010-03-16 16:00:52.000000000 +0000
@@ -298,7 +298,7 @@
def _index_fields(ary, fields):
from multiarray import empty, dtype
dt = ary.dtype
- new_dtype = [(name, dt[name]) for name in fields if name in dt.names]
+ new_dtype = [(name, dt[name]) for name in dt.names if name in fields]
if ary.flags.f_contiguous:
order = 'F'
else:
More information about the NumPy-Discussion
mailing list