8000 DEP: Deprecate setting the strides attribute of a numpy array by eendebakpt · Pull Request #28925 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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 28 commits into from
Jun 20, 2025
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 May 8, 2025
687cf72
update
eendebakpt May 8, 2025
b32319e
add missing changes
eendebakpt May 8, 2025
0fda654
ci
eendebakpt May 8, 2025
d7cfed3
review comments part 1
eendebakpt May 9, 2025
730c9a9
Update doc/release/upcoming_changes/28925.deprecation.rst
eendebakpt May 9, 2025
5874636
Update doc/release/upcoming_changes/28925.deprecation.rst
charris May 11, 2025
2dad334
review comments
eendebakpt May 11, 2025
288690d
apply ruff
eendebakpt May 12, 2025
8502a2f
fix merge issues
eendebakpt May 15, 2025
0c4929e
clarify release notes
eendebakpt May 15, 2025
61eee97
update warning
eendebakpt May 15, 2025
141bbb7
linter
eendebakpt May 15, 2025
88950f2
fix merge conflicts again
eendebakpt May 15, 2025
347b8d3
merge conflicts
eendebakpt May 15, 2025
4bbbfbc
correct ruff version
eendebakpt May 15, 2025
60df1f7
review comment
eendebakpt May 15, 2025
36a8ca0
Merge branch 'main' into array_stride_set
eendebakpt May 18, 2025
bce4d22
ci
eendebakpt May 18, 2025
423fd5a
review comments
eendebakpt May 26, 2025
d8c22e5
Update numpy/_core/src/multiarray/getset.c
seberg May 30, 2025
6ea5c80
Update numpy/_core/src/multiarray/getset.c
eendebakpt Jun 3, 2025
73551a3
Update numpy/__init__.pyi
seberg Jun 3, 2025
01c04e7
Update numpy/__init__.pyi
eendebakpt Jun 4, 2025
bd59c8d
Merge branch 'main' into array_stride_set
eendebakpt Jun 18, 2025
cf1288a
ruff
eendebakpt Jun 19, 2025
88c1261
Merge branch 'main' into array_stride_set
eendebakpt Jun 19, 2025
08d34a2
submodule fix
eendebakpt Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add missing changes
  • Loading branch information
eendebakpt committed May 15, 2025
commit b32319e3a760505565913d6cb2575cdbca89dc38
4 changes: 4 additions & 0 deletions numpy/_core/src/multiarray/getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Copy link
Member

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 and np.lib.stride_tricks.as_strided.

Copy link
Member
@charris charris May 10, 2025

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( DEPRECATE("Setting the strides on a NumPy array has been deprecated in NumPy 2.3.") < 0 ) {
if (DEPRECATE(
"Setting the strides on a NumPy array has been"
" deprecated in NumPy 2.3.") < 0 ) {

return -1;
}

PyArray_Dims newstrides = {NULL, -1};
PyArrayObject *new;
npy_intp numbytes = 0;
Expand Down
0