Skip to content

Replace deprecated usage of numpy array shape, dtype and strides setting #18561

@eendebakpt

Description

@eendebakpt

In Numpy the direct setting of the dtype, shape and strides attributes is being deprecated as these operations are not safe (in particular in the free-threading build). See numpy/numpy#28800 for details.

Most direct setting of the attributes can be replaced with alternatives like array.view(dtype=...) or array.reshape(new_shape). These alternatives have a minor performance penalty (since a new object has to be created), but in general these methods create a view so no data is copied.

The astropy.utils.masked.Masked might be a bit more complex to convert, but can perhaps be handled in the same was as the numpy MaskedArray.

Update: most changes are mechanical changes for which no detailed knowledge of numpy or astropy is required. For a short description on how to approach this see scipy/scipy#23522 (comment)

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