[Numpy-discussion] Structured array copying by field name (was: Numpy 1.6 schedule)

Ralf Gommers ralf.gommers at googlemail.com
Fri Mar 11 04:07:37 EST 2011


On Tue, Mar 8, 2011 at 1:35 AM, Pauli Virtanen <pav at iki.fi> wrote:
>
> Structured array copying copies by field name.
>
> Commit 22d96096bf7d5fb199ca80f2fcd04e8d27815476
>
> Before:
>
>>>> x = np.array([(0, 1)], dtype=[('a', int), ('b', int)])
>>>> y = np.array([(2, 3)], dtype=[('a', int), ('b', int)])
>>>> y = np.array([(2, 3)], dtype=[('b', int), ('a', int)])
>>>> x[:] = y
>>>> x
> array([(2, 3)],
>      dtype=[('a', '<i4'), ('b', '<i4')])
>
> After:
>
>>>> x = np.array([(0, 1)], dtype=[('a', int), ('b', int)])
>>>> y = np.array([(2, 3)], dtype=[('b', int), ('a', int)])
>>>> x[:] = y
>>>> x
> array([(3, 2)],
>      dtype=[('a', '<i4'), ('b', '<i4')])
>
> This seems like a pretty hazardous change. Granted, it's in
> a bit of a grey area, but people may rely on this.

This is still backwards incompatible in current master. Should it be
changed back for 1.6?

Ralf



More information about the NumPy-Discussion mailing list