8000 API: Remove `ptp`, `itemset` and `newbyteorder` from `np.ndarray` class by mtsokol · Pull Request #24682 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: Remove ptp, itemset and newbyteorder from np.ndarray class #24682

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 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Remove remaining .ptp() and .itemset() calls
  • Loading branch information
mtsokol committed Sep 12, 2023
commit 1b249633ec171f4ccb95ab561e47068a574a4155
3 changes: 1 addition & 2 deletions doc/source/reference/arrays.ndarray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ For the following methods there are also corresponding functions in
:func:`clip`, :func:`compress`, :func:`copy`, :func:`cumprod`,
:func:`cumsum`, :func:`diagonal`, :func:`imag`, :func:`max <amax>`,
:func:`mean`, :func:`min <amin>`, :func:`nonzero`, :func:`partition`,
:func:`prod`, :func:`ptp`, :func:`put`, :func:`ravel`, :func:`real`,
:func:`prod`, :func:`put`, :func:`ravel`, :func:`real`,
:func:`repeat`, :func:`reshape`, :func:`round <around>`,
:func:`searchsorted`, :func:`sort`, :func:`squeeze`, :func:`std`,
:func:`sum`, :func:`swapaxes`, :func:`take`, :func:`trace`,
Expand All @@ -290,7 +290,6 @@ Array conversion

ndarray.item
ndarray.tolist
ndarray.itemset
ndarray.tostring
ndarray.tobytes
ndarray.tofile
Expand Down
5 changes: 0 additions & 5 deletions numpy/__init__.pyi
Copy link
Member

Choose a reason for hiding this comment

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

FYI the ndarray.itemset type annotations still persist as of the moment and will have to be removed as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing out! I removed them.

Original file line number Diff line number Diff line change
Expand Up @@ -1535,11 +1535,6 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
/,
) -> _T: ...

@overload
def itemset(self, value: Any, /) -> None: ...
@overload
def itemset(self, item: _ShapeLike, value: Any, /) -> None: ...

@overload
def resize(self, new_shape: _ShapeLike, /, *, refcheck: bool = ...) -> None: ...
@overload
Expand Down
9 changes: 0 additions & 9 deletions numpy/core/tests/test_indexerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ def test_multiindex_exceptions(self):
a = np.empty((5, 0), dtype=object)
assert_raises(IndexError, a.item, (0, 0))

a = np.empty(5, dtype=object)
assert_raises(IndexError, a.itemset, 20, 0)
a = np.empty((5, 0), dtype=object)
assert_raises(IndexError, a.itemset, (0, 0), 0)

def test_put_exceptions(self):
a = np.zeros((5, 5))
assert_raises(IndexError, a.put, 100, 0)
Expand Down Expand Up @@ -127,7 +122,3 @@ def test_methods(self):

a = np.zeros((3, 3))
assert_raises(IndexError, lambda: a.item(100))
assert_raises(IndexError, lambda: a.itemset(100, 1))
a = np.zeros((0, 3))
assert_raises(IndexError, lambda: a.item(100))
assert_raises(IndexError, lambda: a.itemset(100, 1))
5 changes: 2 additions & 3 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_unicode_swapping(self):
ulen = 1
ucs_value = '\U0010FFFF'
ua = np.array([[[ucs_value*ulen]*2]*3]*4, dtype='U%s' % ulen)
ua.view(np.dtype.byteorder()) # Should succeed.
ua.view(ua.dtype.newbyteorder()) # Should succeed.

def test_object_array_fill(self):
# Ticket #86
Expand Down Expand Up @@ -519,7 +519,7 @@ def test_method_args(self):
# Make sure methods and functions have same default axis
# keyword and arguments
funcs1 = ['argmax', 'argmin', 'sum', 'any', 'all', 'cumsum',
'ptp', 'cumprod', 'prod', 'std', 'var', 'mean',
'cumprod', 'prod', 'std', 'var', 'mean',
'round', 'min', 'max', 'argsort', 'sort']
funcs2 = ['compress', 'take', 'repeat']

Expand Down Expand Up @@ -1159,7 +1159,6 @@ def __array_finalize__(self, obj):
assert_(dat.mean(1).info == 'jubba')
assert_(dat.min(1).info == 'jubba')
assert_(dat.prod(1).info == 'jubba')
assert_(dat.ptp(1).info == 'jubba')
assert_(dat.ravel().info == 'jubba')
assert_(dat.real.info == 'jubba')
assert_(dat.repeat(2).info == 'jubba')
Expand Down
2 changes: 1 addition & 1 deletion numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ def test_byteorder_check():
for dtt in (np.float32, np.float64):
arr = np.eye(4, dtype=dtt)
n_arr = arr.view(arr.dtype.newbyteorder(native))
sw_arr = arr.view(array.dtype.newbyteorder("S")).byteswap()
sw_arr = arr.view(arr.dtype.newbyteorder("S")).byteswap()
assert_equal(arr.dtype.byteorder, '=')
for routine in (linalg.inv, linalg.det, linalg.pinv):
# Normal call
Expand Down
6 changes: 3 additions & 3 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3929,13 +3929,13 @@ def test_ptp(self):
# Tests ptp on MaskedArrays.
(x, X, XX, m, mx, mX, mXX, m2x, m2X, m2XX) = self.d
(n, m) = X.shape
assert_equal(mx.ptp(), mx.compressed().ptp())
assert_equal(mx.ptp(), np.ptp(mx.compressed()))
rows = np.zeros(n, float)
cols = np.zeros(m, float)
for k in range(m):
cols[k] = mX[:, k].compressed().ptp()
cols[k] = np.ptp(mX[:, k].compressed())
for k in range(n):
rows[k] = mX[k].compressed().ptp()
rows[k] = np.ptp(mX[k].compressed())
assert_equal(mX.ptp(0), cols)
assert_equal(mX.ptp(1), rows)

Expand Down
0