Skip to content

Structured array drops field-titles when being 'sliced' by field-names #9625

Closed
@axeloide

Description

@axeloide

Is the following behaviour of numpy (v1.13.1) a bug or by design?

>>>import numpy as np
>>>a = np.zeros((1,), dtype=[(('title 1', 'x'), '|i1'), (('title 2', 'y'), '>f4')])

>>>a.dtype.descr
[(('title 1', 'x'), '|i1'), (('title 2', 'y'), '>f4')]

>>>a[['y','x']].dtype.descr
[('y', '>f4'), ('x', '|i1')]

I would have expected the last expression to have returned this instead:
[(('title 2', 'y'), '>f4'), (('title 1', 'x'), '|i1')]

Why are the field-titles missing on a view obtained by indexing?
It is kind of surprising, that some aspects of the structured-array dtype just get dropped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions