Skip to content

Named dtype array: Difference between a[0]['name'] and a['name'][0]? (Trac #2068) #2660

@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/2068 on 2012-02-27 by trac user nschloe, assigned to unknown.

Hi!

I came across the following oddity in numpy which may or may not be a bug:

import numpy as np
dt = np.dtype([('tuple', (int, 2))])
a = np.zeros(3, dt)
type(a['tuple'][0])  % ndarray
type(a[0]['tuple'])  % ndarray

a['tuple'][0] = (1,2)  % ok
a[0]['tuple'] = (1,2)  % ValueError: shape-mismatch on array construction

I would have expected that both of the options below work.
Opinions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions