8000 Numpy structured arrays and logical indexing · Issue #5559 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Numpy structured arrays and logical indexing #5559
Closed
@jmlarson1

Description

@jmlarson1

Assigning values to Numpy structured arrays produces very odd behavior. For example, the following does not assign correctly:

H = np.zeros(4, dtype=[('ind','float')])
H['ind'] = np.arange(1,5)
H['ind']
    array([ 1.,  2.,  3.,  4.])
x = [False, True, False, True]
H['ind'][np.ix_(x)]
    array([ 2.,  4.])
H[np.ix_(x)]['ind'] = [-1, -1]
H
    array([(1.0,), (2.0,), (3.0,), (4.0,)], 
          dtype=[('ind', '<f8')])

If I attempt to make the change recommended here: #3561, it still does not even change the first entry indexed:

H[np.ix_(x)]['ind'][:] = [-1,-1]
H
    array([(1.0,), (2.0,), (3.0,), (4.0,)], 
          dtype=[('ind', '<f8')])

Why might this be the case?

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

      0