DEP: Deprecate ndarray.resize#30181
Conversation
Co-authored-by: Joren Hammudoglu <[email protected]>
|
Will we make type-hint only deprecations a pattern now? FWIW, it seems nice it seems like a nice way to potentially get some feedback about impact (and I guess some libraries may clean it up before there even is a warning, which is a small bonus too)! I do have a slight worry with this one that while it won't be much code that is affected, it may not always be obvious how to replace The least obvious extreme case might be that the resize actually does make sense and one might have to use |
|
Internally, we seem to use it mostly in places where we're reading from a file, and the array should be extended. I think this would often involve a copy (not sure how likely it is memory right after an array allocated earlier is still available). In any python code at least, this is fairly trivially done with |
mhvk
left a comment
There was a problem hiding this comment.
Yes, this seems a good first step!
| @deprecated("Resizing a NumPy array inplace has been deprecated in NumPy 2.4") | ||
| def resize(self, new_shape: _ShapeLike, /, *, refcheck: py_bool = True) -> None: ... | ||
| @overload | ||
| @deprecated("Resizing a NumPy array inplace has been deprecated in NumPy 2.4") |
There was a problem hiding this comment.
Should these have been 2.5?
There was a problem hiding this comment.
I will make a prnto correct this tonight
There was a problem hiding this comment.
Oops, sorry I missed that in review...
Addresses part of #28800
We deprecate
ndarray.resizein the type hints. In a followup PR (probably for a next numpy release) we will issue a deprecating working whenndarray.resizeis called.