Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: ndarray.putmask should respect the writeable flag #17871

Closed
@adlerandy

Description

@adlerandy

Most numpy modify-in-place functions give an error if write=False.
This doesn't happen for np.putmask

a = np.arange(12); a.setflags(write = False)
np.putmask(a, a >= 2, 5)  # Success (Unexpected)
# The expected behaviour is
np.put(a, [3,4],5) # Error "ndarray.put should respect the writeable flag"

This is similar to a previous issue (ndarray.put should respect the writeable flag)
#5132

Surprisingly, putmask calls np.copy, which gives the expected error.
-- Andy

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