summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/code_generators/genapi.py2
-rw-r--r--numpy/core/code_generators/generate_numpy_api.py4
-rw-r--r--numpy/core/einsumfunc.py1
-rw-r--r--numpy/core/records.py6
-rw-r--r--numpy/core/tests/test_deprecations.py3
-rw-r--r--numpy/core/tests/test_extint128.py2
-rw-r--r--numpy/core/tests/test_half.py2
-rw-r--r--numpy/core/tests/test_mem_overlap.py2
-rw-r--r--numpy/core/tests/test_multiarray.py20
-rw-r--r--numpy/core/tests/test_nditer.py3
-rw-r--r--numpy/core/tests/test_numeric.py2
-rw-r--r--numpy/core/tests/test_records.py3
-rw-r--r--numpy/core/tests/test_regression.py4
-rw-r--r--numpy/core/tests/test_scalarinherit.py5
-rw-r--r--numpy/core/tests/test_scalarmath.py4
-rw-r--r--numpy/core/tests/test_scalarprint.py2
-rw-r--r--numpy/core/tests/test_shape_base.py3
-rw-r--r--numpy/core/tests/test_umath.py4
18 files changed, 31 insertions, 41 deletions
diff --git a/numpy/core/code_generators/genapi.py b/numpy/core/code_generators/genapi.py
index 3dc68c5ef..1d2cd25c8 100644
--- a/numpy/core/code_generators/genapi.py
+++ b/numpy/core/code_generators/genapi.py
@@ -163,9 +163,7 @@ def skip_brackets(s, lbrac, rbrac):
def split_arguments(argstr):
arguments = []
- bracket_counts = {'(': 0, '[': 0}
current_argument = []
- state = 0
i = 0
def finish_arg():
if current_argument:
diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py
index a883ee469..5e04fb86d 100644
--- a/numpy/core/code_generators/generate_numpy_api.py
+++ b/numpy/core/code_generators/generate_numpy_api.py
@@ -192,7 +192,9 @@ def do_generate_api(targets, sources):
genapi.check_api_dict(multiarray_api_index)
numpyapi_list = genapi.get_api_functions('NUMPY_API',
- multiarray_funcs)
+ multiarray_funcs)
+
+ # FIXME: ordered_funcs_api is unused
ordered_funcs_api = genapi.order_dict(multiarray_funcs)
# Create dict name -> *Api instance
diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py
index 832ff3057..c4fc77e9e 100644
--- a/numpy/core/einsumfunc.py
+++ b/numpy/core/einsumfunc.py
@@ -849,7 +849,6 @@ def einsum_path(*operands, **kwargs):
# Python side parsing
input_subscripts, output_subscript, operands = _parse_einsum_input(operands)
- subscripts = input_subscripts + '->' + output_subscript
# Build a few useful list and sets
input_list = input_subscripts.split(',')
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 9e09e46b3..86a43306a 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -783,13 +783,13 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None,
itemsize = descr.itemsize
- shapeprod = sb.array(shape).prod()
+ shapeprod = sb.array(shape).prod(dtype=nt.intp)
shapesize = shapeprod * itemsize
if shapesize < 0:
shape = list(shape)
- shape[shape.index(-1)] = size / -shapesize
+ shape[shape.index(-1)] = size // -shapesize
shape = tuple(shape)
- shapeprod = sb.array(shape).prod()
+ shapeprod = sb.array(shape).prod(dtype=nt.intp)
nbytes = shapeprod * itemsize
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 7e6e256fe..edb5d5e46 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -13,8 +13,7 @@ import pytest
import numpy as np
from numpy.testing import (
- assert_raises, assert_warns, assert_no_warnings, assert_array_equal,
- assert_
+ assert_raises, assert_warns, assert_
)
try:
diff --git a/numpy/core/tests/test_extint128.py b/numpy/core/tests/test_extint128.py
index 0e9c07fd5..7c454a603 100644
--- a/numpy/core/tests/test_extint128.py
+++ b/numpy/core/tests/test_extint128.py
@@ -1,6 +1,5 @@
from __future__ import division, absolute_import, print_function
-import sys
import itertools
import contextlib
import operator
@@ -8,7 +7,6 @@ import pytest
import numpy as np
import numpy.core._multiarray_tests as mt
-from numpy.compat import long
from numpy.testing import assert_raises, assert_equal
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
index 2f2d069e5..b28c933db 100644
--- a/numpy/core/tests/test_half.py
+++ b/numpy/core/tests/test_half.py
@@ -5,7 +5,7 @@ import pytest
import numpy as np
from numpy import uint16, float16, float32, float64
-from numpy.testing import assert_, assert_equal, suppress_warnings
+from numpy.testing import assert_, assert_equal
def assert_raises_fpe(strmatch, callable, *args, **kwargs):
diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py
index f4ce6a84a..3c8e0e722 100644
--- a/numpy/core/tests/test_mem_overlap.py
+++ b/numpy/core/tests/test_mem_overlap.py
@@ -10,7 +10,7 @@ from numpy.core import _umath_tests
from numpy.lib.stride_tricks import as_strided
from numpy.compat import long
from numpy.testing import (
- assert_, assert_raises, assert_equal, assert_array_equal, assert_allclose
+ assert_, assert_raises, assert_equal, assert_array_equal
)
if sys.version_info[0] >= 3:
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 1f19cb461..311b477f5 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -3652,7 +3652,6 @@ class TestPickling(object):
'protocol 5 although it is not available'))
def test_correct_protocol5_error_message(self):
array = np.arange(10)
- f = io.BytesIO()
if sys.version_info[:2] in ((3, 6), (3, 7)):
# For the specific case of python3.6 and 3.7, raise a clear import
@@ -4926,11 +4925,11 @@ class TestRecord(object):
assert_equal(dt.names, ['p', 'q'])
def test_multiple_field_name_occurrence(self):
- def test_assign():
- dtype = np.dtype([("A", "f8"), ("B", "f8"), ("A", "f8")])
+ def test_dtype_init():
+ np.dtype([("A", "f8"), ("B", "f8"), ("A", "f8")])
# Error raised when multiple fields have the same name
- assert_raises(ValueError, test_assign)
+ assert_raises(ValueError, test_dtype_init)
@pytest.mark.skipif(sys.version_info[0] < 3, reason="Not Python 3")
def test_bytes_fields(self):
@@ -4950,13 +4949,11 @@ class TestRecord(object):
@pytest.mark.skipif(sys.version_info[0] < 3, reason="Not Python 3")
def test_multiple_field_name_unicode(self):
- def test_assign_unicode():
- dt = np.dtype([("\u20B9", "f8"),
- ("B", "f8"),
- ("\u20B9", "f8")])
+ def test_dtype_unicode():
+ np.dtype([("\u20B9", "f8"), ("B", "f8"), ("\u20B9", "f8")])
# Error raised when multiple fields have the same name(unicode included)
- assert_raises(ValueError, test_assign_unicode)
+ assert_raises(ValueError, test_dtype_unicode)
@pytest.mark.skipif(sys.version_info[0] >= 3, reason="Not Python 2")
def test_unicode_field_titles(self):
@@ -6918,7 +6915,7 @@ class TestNewBufferProtocol(object):
# gh-11150, due to bpo-10746
for c_integer in {ctypes.c_int, ctypes.c_long, ctypes.c_longlong}:
value = c_integer(42)
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.filterwarnings('always', r'.*\bctypes\b', RuntimeWarning)
np.asarray(value)
@@ -6928,7 +6925,7 @@ class TestNewBufferProtocol(object):
_fields_ = [('a', ctypes.c_uint8), ('b', ctypes.c_uint32)]
f = foo(a=1, b=2)
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.filterwarnings('always', r'.*\bctypes\b', RuntimeWarning)
arr = np.asarray(f)
@@ -7618,6 +7615,7 @@ class TestWritebackIfCopy(object):
mat = np.eye(5)
out = np.eye(5, dtype='i2')
res = np.clip(mat, a_min=-10, a_max=0, out=out)
+ assert_(res is out)
assert_equal(np.sum(out), 0)
def test_insert_noncontiguous(self):
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py
index 9f718d63b..26fd9c346 100644
--- a/numpy/core/tests/test_nditer.py
+++ b/numpy/core/tests/test_nditer.py
@@ -1,14 +1,13 @@
from __future__ import division, absolute_import, print_function
import sys
-import warnings
import pytest
import numpy as np
import numpy.core._multiarray_tests as _multiarray_tests
from numpy import array, arange, nditer, all
from numpy.testing import (
- assert_, assert_equal, assert_array_equal, assert_raises, assert_warns,
+ assert_, assert_equal, assert_array_equal, assert_raises,
HAS_REFCOUNT, suppress_warnings
)
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index f264c4ab0..37534720a 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -13,7 +13,7 @@ from numpy.random import rand, randint, randn
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
- suppress_warnings, HAS_REFCOUNT
+ HAS_REFCOUNT
)
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index 11f2e4175..c059ef510 100644
--- a/numpy/core/tests/test_records.py
+++ b/numpy/core/tests/test_records.py
@@ -7,7 +7,6 @@ try:
import collections.abc as collections_abc
except ImportError:
import collections as collections_abc
-import warnings
import textwrap
from os import path
import pytest
@@ -16,7 +15,7 @@ import numpy as np
from numpy.compat import Path
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
- assert_raises, assert_warns, temppath
+ assert_raises, temppath
)
from numpy.core.numeric import pickle
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index a929b0efd..2421a1161 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -2,9 +2,7 @@ from __future__ import division, absolute_import, print_function
import copy
import sys
-import platform
import gc
-import warnings
import tempfile
import pytest
from os import path
@@ -2409,7 +2407,7 @@ class TestRegression(object):
t = np.dtype([((s, 'f1'), np.float64)])
data = np.zeros(10, t)
for i in range(10):
- v = str(data[['f1']])
+ str(data[['f1']])
if HAS_REFCOUNT:
assert_(base <= sys.getrefcount(s))
diff --git a/numpy/core/tests/test_scalarinherit.py b/numpy/core/tests/test_scalarinherit.py
index 28436f6c7..9e32cf624 100644
--- a/numpy/core/tests/test_scalarinherit.py
+++ b/numpy/core/tests/test_scalarinherit.py
@@ -69,6 +69,7 @@ class TestCharacter(object):
np_s = np.string_('abc')
np_u = np.unicode_('abc')
np_i = np.int(5)
- res_np = np_s * np_i
res_s = b'abc' * 5
- assert_(res_np == res_s)
+ res_u = u'abc' * 5
+ assert_(np_s * np_i == res_s)
+ assert_(np_u * np_i == res_u)
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index 423e437f1..51bcf2b8d 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -9,7 +9,7 @@ import pytest
import numpy as np
from numpy.testing import (
- assert_, assert_equal, assert_raises, assert_almost_equal, assert_allclose,
+ assert_, assert_equal, assert_raises, assert_almost_equal,
assert_array_equal, IS_PYPY, suppress_warnings, _gen_alignment_data,
assert_warns
)
@@ -184,7 +184,7 @@ class TestPower(object):
a = 5
b = 4
c = 10
- expected = pow(a, b, c)
+ expected = pow(a, b, c) # noqa: F841
for t in (np.int32, np.float32, np.complex64):
# note that 3-operand power only dispatches on the first argument
assert_raises(TypeError, operator.pow, t(a), b, c)
diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py
index 472ff691d..cde1355aa 100644
--- a/numpy/core/tests/test_scalarprint.py
+++ b/numpy/core/tests/test_scalarprint.py
@@ -10,7 +10,7 @@ import pytest
from tempfile import TemporaryFile
import numpy as np
-from numpy.testing import assert_, assert_equal, suppress_warnings, dec
+from numpy.testing import assert_, assert_equal, suppress_warnings
class TestRealScalars(object):
def test_str(self):
diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py
index 416bd18db..ef5c118ec 100644
--- a/numpy/core/tests/test_shape_base.py
+++ b/numpy/core/tests/test_shape_base.py
@@ -1,7 +1,6 @@
from __future__ import division, absolute_import, print_function
import pytest
-import warnings
import sys
import numpy as np
from numpy.core import (
@@ -12,7 +11,7 @@ from numpy.core.shape_base import (_block_dispatcher, _block_setup,
_block_concatenate, _block_slicing)
from numpy.testing import (
assert_, assert_raises, assert_array_equal, assert_equal,
- assert_raises_regex, assert_warns, assert_almost_equal
+ assert_raises_regex, assert_warns
)
from numpy.compat import long
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index fe23c922b..2f8edebc0 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -1,6 +1,5 @@
from __future__ import division, absolute_import, print_function
-import sys
import platform
import warnings
import fnmatch
@@ -14,7 +13,7 @@ from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
assert_allclose, assert_no_warnings, suppress_warnings,
- _gen_alignment_data, assert_warns
+ _gen_alignment_data
)
@@ -1298,6 +1297,7 @@ class TestSign(object):
# In reference to github issue #6229
def test_nan():
foo = np.array([np.nan])
+ # FIXME: a not used
a = np.sign(foo.astype(object))
assert_raises(TypeError, test_nan)