[Numpy-discussion] Documentation for dtypes with named fields
Tue Mar 16 11:23:48 CDT 2010
On Tue, Mar 16, 2010 at 12:04 PM, Sam Tygier
> On Tue, Mar 16, 2010 at 11:34 AM, Skipper Seabold <firstname.lastname@example.org> 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'
You can file a ticket, but if this is a function that is already in
real use, then it would be an unpleasant break in the API
> NumPy-Discussion mailing list
More information about the NumPy-Discussion