8000 API: remove selected numpy.lib warning suppressions · numpy/numpy@b119f44 · GitHub
[go: up one dir, main page]

Skip to content

Commit b119f44

Browse files
committed
API: remove selected numpy.lib warning suppressions
1 parent 2f36ac5 commit b119f44

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

numpy/core/_methods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from numpy.core import umath as um
1313
from numpy.core.multiarray import asanyarray
1414
from numpy.core import numerictypes as nt
15+
from numpy.core import _exceptions
1516
from numpy.core._ufunc_config import _no_nep50_warning
1617
from numpy._globals import _NoValue
1718

numpy/lib/format.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
import warnings
168168

169169
import numpy
170-
from numpy.lib.utils import safe_eval, drop_metadata
170+
from numpy.lib.utils import drop_metadata
171171

172172

173173
__all__ = []
@@ -591,6 +591,7 @@ def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE):
591591
"""
592592
# Read an unsigned, little-endian short int which has the length of the
593593
# header.
594+
import ast
594595
import struct
595596
hinfo = _header_size_info.get(version)
596597
if hinfo is None:
@@ -621,12 +622,12 @@ def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE):
621622
#
622623
# For performance reasons, we try without _filter_header first though
623624
try:
624-
d = safe_eval(header)
625+
d = ast.literal_eval(header)
625626
except SyntaxError as e:
626627
if version <= (2, 0):
627628
header = _filter_header(header)
628629
try:
629-
d = safe_eval(header)
630+
d = ast.literal_eval(header)
630631
except SyntaxError as e2:
631632
msg = "Cannot parse header: {!r}"
632633
raise ValueError(msg.format(header)) from e2

numpy/lib/tests/test_regression.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
66
assert_raises, _assert_valid_refcount,
77
)
8+
import pytest
89

910

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

161+
@pytest.mark.filterwarnings("ignore:.*who.*:DeprecationWarning")
160162
def test_who_with_0dim_array(self):
161163
# ticket #1243
162164
import os

numpy/lib/tests/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ def test_deprecate_module():
120120
assert_(old_func.__module__ == __name__)
121121

122122

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

127128

129+
@pytest.mark.filterwarnings("ignore:.*byte_bounds.*:DeprecationWarning")
128130
class TestByteBounds:
129131

130132
def test_byte_bounds(self):

pytest.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,3 @@ filterwarnings =
2727
ignore:\n\n `numpy.distutils`:DeprecationWarning
2828
# Ignore mypy >= 0.971 DeprecationWarnings
2929
ignore:path is deprecated\. Use files\(\) instead:DeprecationWarning:mypy
30-
# Ignore selected DeprecationWarnings from numpy.lib
31-
ignore:.*`safe_eval` is deprecated!:DeprecationWarning
32-
ignore:.*`byte_bounds` is deprecated!:DeprecationWarning
33-
ignore:.*`who` is deprecated!:DeprecationWarning

0 commit comments

Comments
 (0)
0