-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
DEP: Deprecate setting the strides attribute of a numpy array #28925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
18c02c8
DEP: Deprecate setting the strides attribute of a numpy array
eendebakpt 687cf72
update
eendebakpt b32319e
add missing changes
eendebakpt 0fda654
ci
eendebakpt d7cfed3
review comments part 1
eendebakpt 730c9a9
Update doc/release/upcoming_changes/28925.deprecation.rst
eendebakpt 5874636
Update doc/release/upcoming_changes/28925.deprecation.rst
charris 2dad334
review comments
eendebakpt 288690d
apply ruff
eendebakpt 8502a2f
fix merge issues
eendebakpt 0c4929e
clarify release notes
eendebakpt 61eee97
update warning
eendebakpt 141bbb7
linter
eendebakpt 88950f2
fix merge conflicts again
eendebakpt 347b8d3
merge conflicts
eendebakpt 4bbbfbc
correct ruff version
eendebakpt 60df1f7
review comment
eendebakpt 36a8ca0
Merge branch 'main' into array_stride_set
eendebakpt bce4d22
ci
eendebakpt 423fd5a
review comments
eendebakpt d8c22e5
Update numpy/_core/src/multiarray/getset.c
seberg 6ea5c80
Update numpy/_core/src/multiarray/getset.c
eendebakpt 73551a3
Update numpy/__init__.pyi
seberg 01c04e7
Update numpy/__init__.pyi
eendebakpt bd59c8d
Merge branch 'main' into array_stride_set
eendebakpt cf1288a
ruff
eendebakpt 88c1261
Merge branch 'main' into array_stride_set
eendebakpt 08d34a2
submodule fix
eendebakpt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add missing changes
- Loading branch information
commit b32319e3a760505565913d6cb2575cdbca89dc38
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -116,6 +116,10 @@ array_strides_get(PyArrayObject *self, void *NPY_UNUSED(ignored)) | |||||||||
static int | ||||||||||
array_strides_set(PyArrayObject *self, PyObject *obj, void *NPY_UNUSED(ignored)) | ||||||||||
{ | ||||||||||
if( DEPRECATE("Setting the strides on a NumPy array has been deprecated in NumPy 2.3.") < 0 ) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
return -1; | ||||||||||
} | ||||||||||
|
||||||||||
PyArray_Dims newstrides = {NULL, -1}; | ||||||||||
PyArrayObject *new; | ||||||||||
npy_intp numbytes = 0; | ||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be nice to point out the work-arounds, but considerin 10000 g that stride setting is a bit niche maybe we can also just do that in the release note.
Something like: See
np.lib.stride_tricks.strided_window_view
andnp.lib.stride_tricks.as_strided
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here is a long line, which needs space fixes also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are at it, adding a
/* Deprecated NumPy 2.3, 2025-05-11 */
above it would also be nice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the warning needs a suggestion for what to do instead and maybe a pointer to stride_tricks if someone really does need to mutate the strides of an existing array.