-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Description
As seen in #28727, mutating arrays like this is dangerous in surprising ways, particularly on the free-threaded build.
We should guide people towards safer alternatives that create new views or copies of arrays instead of mutating.
We should first try deprecating strides and dtype, then shape, since we expect that setting shape is used the most (before np.reshape it was the only way to do it).
To do the actual deprecation, first someone needs to add the warning and deal with any fallout in the NumPy tests. Make sure the deprecation warnings indicate clearly how to update affected code. It would also be good to look at some downstream libraries like SciPy, matplotlib, pandas, and scikit-learn to see how much noise these deprecations cause in downstream tests.
If it isn't too bad and the fixes are straightforward, we should be good to go.
- Deprecate setting strides (DEP: Deprecate setting the strides attribute of a numpy array #28925)
- Deprecate setting dtype (DEP: Deprecate setting the dtype of an numpy.ndarray #29575, DEP: Deprecate setting the dtype of an exact numpy.ndarray #29244)
- Deprecate setting shape (DEP: Deprecate setting the shape attribute of a numpy array #29536, DEP: Deprecate setting the shape attribute of an exact numpy array #29523)
- Deprecate
ndarray.resizeand thusPyArray_Resize.