10000 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
Show file tree
Hide file tree
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
fix merge issues
  • Loading branch information
eendebakpt committed May 15, 2025
commit 8502a2f4bef1456eb32a34b52f5dcae2dd86a079
5 changes: 0 additions & 5 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,8 @@ from typing import (
# if not available at runtime. This is because the `typeshed` stubs for the standard
# library include `typing_extensions` stubs:
# https://github.com/python/typeshed/blob/main/stdlib/typing_extensions.pyi
<<<<<<< HEAD
from _typeshed import Incomplete, StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite
from typing_extensions import CapsuleType, TypeVar
=======
from _typeshed import StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite
from typing_extensions import deprecated, CapsuleType, TypeVar
>>>>>>> 10ccc58f0b (DEP: Deprecate setting the strides attribute of a numpy array)

from numpy import (
char,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/src/multiarray/getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ array_strides_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
static int
array_strides_set(PyArrayObject *self, PyObject *obj, void *NPY_UNUSED(ignored))
{
if (obj == NULL) {
if (obj == NULL || 1) {
PyErr_SetString(PyExc_AttributeError,
"Cannot delete array strides");
return -1;
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def func(arg1, /, arg2, *, arg3):
import threading

import pytest

import numpy as np
from numpy._core._multiarray_tests import (
argparse_example_function as func,
)
from numpy._core._multiarray_tests import (
threaded_argparse_example_function as thread_func,
)

import numpy as np
from numpy.testing import IS_WASM


Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_array_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from itertools import permutations, product

import numpy._core._multiarray_umath as ncu
import pytest
from numpy._core._rational_tests import rational
from pytest import param

import numpy as np
import numpy._core._multiarray_umath as ncu
from numpy._core._rational_tests import rational
from numpy.testing import IS_64BIT, IS_PYPY, assert_array_equal


Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_arraymethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from typing import Any

import pytest
from numpy._core._multiarray_umath import _get_castingimpl as get_castingimpl

import numpy as np
from numpy._core._multiarray_umath import _get_castingimpl as get_castingimpl


class TestResolveDescriptors:
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_casting_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import textwrap

import pytest
from numpy._core._multiarray_umath import _get_castingimpl as get_castingimpl

import numpy as np
from numpy._core._multiarray_umath import _get_castingimpl as get_castingimpl
from numpy.lib.stride_tricks import as_strided
from numpy.testing import assert_array_equal

Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_conversion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""
import re

import numpy._core._multiarray_tests as mt
import pytest

import numpy._core._multiarray_tests as mt
from numpy._core.multiarray import CLIP, RAISE, WRAP
from numpy.testing import assert_raises

Expand Down
3 changes: 1 addition & 2 deletions numpy/_core/tests/test_cpu_dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from numpy._core import _umath_tests
from numpy._core._multiarray_umath import (
__cpu_baseline__,
__cpu_dispatch__,
__cpu_features__,
)

from numpy._core import _umath_tests
from numpy.testing import assert_equal


Expand Down
1 change: 1 addition & 0 deletions numpy/_core/tests/test_cpu_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys

import pytest

from numpy._core._multiarray_umath import (
__cpu_baseline__,
__cpu_dispatch__,
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_custom_dtypes.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from tempfile import NamedTemporaryFile

import pytest

import numpy as np
from numpy._core._multiarray_umath import (
_discover_array_parameters as discover_array_params,
)
from numpy._core._multiarray_umath import _get_sfloat_dtype

import numpy as np
from numpy.testing import assert_array_equal

SF = _get_sfloat_dtype()
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"""
import warnings

import numpy._core._struct_ufunc_tests as struct_ufunc
import pytest
from numpy._core._multiarray_tests import fromstring_null_term_c_api # noqa: F401

import numpy as np
import numpy._core._struct_ufunc_tests as struct_ufunc
from numpy._core._multiarray_tests import fromstring_null_term_c_api # noqa: F401
from numpy.testing import assert_raises, temppath

try:
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import hypothesis
import pytest
from hypothesis.extra import numpy as hynp
from numpy._core._multiarray_tests import create_custom_field_dtype
from numpy._core._rational_tests import rational

import numpy as np
import numpy.dtypes
from numpy._core._multiarray_tests import create_custom_field_dtype
from numpy._core._rational_tests import rational
from numpy.testing import (
HAS_REFCOUNT,
IS_PYSTON,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_extint128.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import itertools
import operator

import numpy._core._multiarray_tests as mt
import pytest

import numpy as np
import numpy._core._multiarray_tests as mt
from numpy.testing import assert_equal, assert_raises

INT64_MAX = np.iinfo(np.int64).max
Expand Down
1 change: 1 addition & 0 deletions numpy/_core/tests/test_hashtable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random

import pytest

from numpy._core._multiarray_tests import identityhash_tester


Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from itertools import product

import pytest
from numpy._core._multiarray_tests import array_indexing

import numpy as np
from numpy._core._multiarray_tests import array_indexing
from numpy.exceptions import ComplexWarning, VisibleDeprecationWarning
from numpy.testing import (
HAS_REFCOUNT,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_mem_overlap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import itertools

import pytest
from numpy._core._multiarray_tests import internal_overlap, solve_diophantine

import numpy as np
from numpy._core import _umath_tests
from numpy._core._multiarray_tests import internal_overlap, solve_diophantine
from numpy.lib.stride_tricks import as_strided
from numpy.testing import assert_, assert_array_equal, assert_equal, assert_raises

Expand Down
22 changes: 3 additions & 19 deletions numpy/_core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@
import weakref
from contextlib import contextmanager

import numpy as np
import numpy._core._multiarray_tests as _multiarray_tests
from numpy._core._rational_tests import rational
from numpy.exceptions import AxisError, ComplexWarning
from numpy.testing import (
assert_, assert_raises, assert_warns, assert_equal, assert_almost_equal,
assert_array_equal, assert_raises_regex, assert_array_almost_equal,
assert_allclose, IS_PYPY, IS_WASM, IS_PYSTON, HAS_REFCOUNT,
assert_array_less, runstring, temppath, suppress_warnings, break_cycles,
check_support_sve, assert_array_compare, IS_64BIT
)
from numpy.testing._private.utils import requires_memory, _no_tracing
from numpy._core.tests._locales import CommaDecimalPointLocale
from numpy.lib.recfunctions import repack_fields
from numpy._core.multiarray import _get_ndarray_c_version, dot
from numpy.lib import stride_tricks

# Need to test an object that does not fully implement math interface
from datetime import datetime, timedelta
from decimal import Decimal

import numpy._core._multiarray_tests as _multiarray_tests
import pytest
from numpy._core._rational_tests import rational

import numpy as np
import numpy._core._multiarray_tests as _multiarray_tests
from numpy._core._rational_tests import rational
from numpy._core.multiarray import _get_ndarray_c_version, dot
from numpy._core.tests._locales import CommaDecimalPointLocale
from numpy.exceptions import AxisError, ComplexWarning
from numpy.lib import stride_tricks
from numpy.lib.recfunctions import repack_fields
from numpy.testing import (
HAS_REFCOUNT,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_nditer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import sys
import textwrap

import numpy._core._multiarray_tests as _multiarray_tests
import pytest

import numpy as np
import numpy._core._multiarray_tests as _multiarray_tests
import numpy._core.umath as ncu
from numpy import all, arange, array, nditer
from numpy.testing import (
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from hypothesis import given
from hypothesis import strategies as st
from hypothesis.extra import numpy as hynp
from numpy._core._rational_tests import rational

import numpy as np
from numpy import ma
from numpy._core import sctypes
from numpy._core._rational_tests import rational
from numpy._core.numerictypes import obj2sctype
from numpy.exceptions import AxisError
from numpy.random import rand, randint, randn
Expand Down
1 change: 1 addition & 0 deletions numpy/_core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
)
from numpy.testing._private.utils import _no_tracing, requires_memory


class TestRegression:
def test_invalid_round(self):
# Ticket #3
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_scalarbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Test scalar buffer interface adheres to PEP 3118
"""
import pytest
from numpy._core._multiarray_tests import get_buffer_info
from numpy._core._rational_tests import rational

import numpy as np
from numpy._core._multiarray_tests import get_buffer_info
from numpy._core._rational_tests import rational
from numpy.testing import assert_, assert_equal, assert_raises

# PEP3118 format strings for native (standard alignment and byteorder) types
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_scalarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from hypothesis import given, settings
from hypothesis.extra import numpy as hynp
from hypothesis.strategies import sampled_from
from numpy._core._rational_tests import rational

import numpy as np
from numpy._core._rational_tests import rational
from numpy._utils import _pep440
from numpy.exceptions import ComplexWarning
from numpy.testing import (
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_simd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import re

import pytest
from numpy._core._multiarray_umath import __cpu_baseline__

from numpy._core._multiarray_umath import __cpu_baseline__
from numpy._core._simd import clear_floatstatus, get_floatstatus, targets


Expand Down
6 changes: 3 additions & 3 deletions numpy/_core/tests/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import sys
import warnings

import numpy._core._operand_flag_tests as opflag_tests
import numpy._core._rational_tests as _rational_tests
import numpy._core._umath_tests as umt
import pytest
from pytest import param

import numpy as np
import numpy._core._operand_flag_tests as opflag_tests
import numpy._core._rational_tests as _rational_tests
import numpy._core._umath_tests as umt
import numpy._core.umath as ncu
import numpy.linalg._umath_linalg as uml
from numpy.exceptions import AxisError
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_umath_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from os import path

import pytest
from numpy._core._multiarray_umath import __cpu_features__

import numpy as np
from numpy._core._multiarray_umath import __cpu_features__
from numpy.testing import assert_array_max_ulp
from numpy.testing._private.utils import _glibc_older_than

Expand Down
5 changes: 3 additions & 2 deletions numpy/_core/tests/test_umath_complex.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import platform
import sys

# import the c-extension module directly since _arg is not exported via umath
import numpy._core._multiarray_umath as ncu
import pytest

import numpy as np

# import the c-extension module directly since _arg is not exported via umath
import numpy._core._multiarray_umath as ncu
from numpy.testing import (
assert_almost_equal,
assert_array_equal,
Expand Down
Loading
0