8000 API: deprecate compat and selected lib utils by mtsokol · Pull Request #23830 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: deprecate compat and selected lib utils #23830

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 3 commits into from
Jun 14, 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
API: remove selected numpy.lib warning suppressions
  • Loading branch information
mtsokol committed Jun 14, 2023
commit 22d9ffb1d9d68ea5eafa9a348f547b4d3a9af72c
1 change: 1 addition & 0 deletions numpy/core/_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globals import _NoValue

Expand Down
7 changes: 4 additions & 3 deletions numpy/lib/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
import warnings

import numpy
from numpy.lib.utils import safe_eval, drop_metadata
from numpy.lib.utils import drop_metadata


__all__ = []
Expand Down Expand Up @@ -591,6 +591,7 @@ def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE):
"""
# Read an unsigned, little-endian short int which has the length of the
# header.
import ast
import struct
hinfo = _header_size_info.get(version)
if hinfo is None:
Expand Down Expand Up @@ -621,12 +622,12 @@ def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE):
#
# For performance reasons, we try without _filter_header first though
try:
d = safe_eval(header)
d = ast.literal_eval(header)
except SyntaxError as e:
if version <= (2, 0):
header = _filter_header(header)
try:
d = safe_eval(header)
d = ast.literal_eval(header)
except SyntaxError as e2:
msg = "Cannot parse header: {!r}"
raise ValueError(msg.format(header)) from e2
Expand Down
2 changes: 2 additions & 0 deletions numpy/lib/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
assert_raises, _assert_valid_refcount,
)
import pytest


class TestRegression:
Expand Down Expand Up @@ -157,6 +158,7 @@ def test_void_coercion(self):
x = np.zeros((1,), dt)
assert_(np.r_[x, x].dtype == dt)

@pytest.mark.filterwarnings("ignore:.*who.*:DeprecationWarning")
def test_who_with_0dim_array(self):
# ticket #1243
import os
Expand Down
2 changes: 2 additions & 0 deletions numpy/lib/tests/test_utils.py
< 8000 td id="diff-23fe7e18de61fffa31b5e26d53696ad52b4dc3ec27fbb4ef4446d1a57833684aR125" data-line-number="125" class="blob-num blob-num-context js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ def test_deprecate_module():
assert_(old_func.__module__ == __name__)


@pytest.mark.filterwarnings("ignore:.*safe_eval.*:DeprecationWarning")
def test_safe_eval_nameconstant():
# Test if safe_eval supports Python 3.4 _ast.NameConstant
utils.safe_eval('None')


@pytest.mark.filterwarnings("ignore:.*byte_bounds.*:DeprecationWarning")
class TestByteBounds:

def test_byte_bounds(self):
Expand Down
4 changes: 0 additions & 4 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ filterwarnings =
ignore:\n\n `numpy.distutils`:DeprecationWarning
# Ignore mypy >= 0.971 DeprecationWarnings
ignore:path is deprecated\. Use files\(\) instead:DeprecationWarning:mypy
# Ignore selected DeprecationWarnings from numpy.lib
ignore:.*`safe_eval` is deprecated!:DeprecationWarning
ignore:.*`byte_bounds` is deprecated!:DeprecationWarning
ignore:.*`who` is deprecated!:DeprecationWarning
0