summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-08-01 20:29:36 +0000
committerCharles Harris <charlesr.harris@gmail.com>2017-08-05 10:36:48 -0600
commit2b781f8967488dc007f8f0a1e6a7f49208788d12 (patch)
tree88ad7478e033ce5980a365a479e22b78ba1cecaa /numpy/core
parent5ab02b15de72fa00d785f49c62466fe048264cc4 (diff)
downloadnumpy-2b781f8967488dc007f8f0a1e6a7f49208788d12.tar.gz
MAINT/DOC: Use builtin when np.{x} is builtins.{x}.
This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/fromnumeric.py6
-rw-r--r--numpy/core/numeric.py8
-rw-r--r--numpy/core/numerictypes.py18
-rw-r--r--numpy/core/tests/test_deprecations.py2
-rw-r--r--numpy/core/tests/test_dtype.py56
-rw-r--r--numpy/core/tests/test_half.py2
-rw-r--r--numpy/core/tests/test_item_selection.py2
-rw-r--r--numpy/core/tests/test_multiarray.py82
-rw-r--r--numpy/core/tests/test_nditer.py2
-rw-r--r--numpy/core/tests/test_numeric.py38
-rw-r--r--numpy/core/tests/test_print.py6
-rw-r--r--numpy/core/tests/test_records.py6
-rw-r--r--numpy/core/tests/test_regression.py12
-rw-r--r--numpy/core/tests/test_scalarmath.py2
-rw-r--r--numpy/core/tests/test_ufunc.py22
-rw-r--r--numpy/core/tests/test_umath.py48
-rw-r--r--numpy/core/tests/test_umath_complex.py86
17 files changed, 199 insertions, 199 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 4922fc3e4..338248ce3 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -2246,7 +2246,7 @@ def amax(a, axis=None, out=None, keepdims=np._NoValue):
>>> np.amax(a, axis=1) # Maxima along the second axis
array([1, 3])
- >>> b = np.arange(5, dtype=np.float)
+ >>> b = np.arange(5, dtype=float)
>>> b[2] = np.NaN
>>> np.amax(b)
nan
@@ -2347,7 +2347,7 @@ def amin(a, axis=None, out=None, keepdims=np._NoValue):
>>> np.amin(a, axis=1) # Minima along the second axis
array([0, 2])
- >>> b = np.arange(5, dtype=np.float)
+ >>> b = np.arange(5, dtype=float)
>>> b[2] = np.NaN
>>> np.amin(b)
nan
@@ -2497,7 +2497,7 @@ def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
is the default platform integer:
>>> x = np.array([1, 2, 3], dtype=np.int8)
- >>> np.prod(x).dtype == np.int
+ >>> np.prod(x).dtype == int
True
"""
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 02f9be3a9..13a99505c 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -133,7 +133,7 @@ def zeros_like(a, dtype=None, order='K', subok=True):
array([[0, 0, 0],
[0, 0, 0]])
- >>> y = np.arange(3, dtype=np.float)
+ >>> y = np.arange(3, dtype=float)
>>> y
array([ 0., 1., 2.])
>>> np.zeros_like(y)
@@ -176,7 +176,7 @@ def ones(shape, dtype=None, order='C'):
>>> np.ones(5)
array([ 1., 1., 1., 1., 1.])
- >>> np.ones((5,), dtype=np.int)
+ >>> np.ones((5,), dtype=int)
array([1, 1, 1, 1, 1])
>>> np.ones((2, 1))
@@ -243,7 +243,7 @@ def ones_like(a, dtype=None, order='K', subok=True):
array([[1, 1, 1],
[1, 1, 1]])
- >>> y = np.arange(3, dtype=np.float)
+ >>> y = np.arange(3, dtype=float)
>>> y
array([ 0., 1., 2.])
>>> np.ones_like(y)
@@ -344,7 +344,7 @@ def full_like(a, fill_value, dtype=None, order='K', subok=True):
Examples
--------
- >>> x = np.arange(6, dtype=np.int)
+ >>> x = np.arange(6, dtype=int)
>>> np.full_like(x, 1)
array([1, 1, 1, 1, 1, 1])
>>> np.full_like(x, 0.1)
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index be3829ea1..136081412 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -501,11 +501,11 @@ def maximum_sctype(t):
Examples
--------
- >>> np.maximum_sctype(np.int)
+ >>> np.maximum_sctype(int)
<type 'numpy.int64'>
>>> np.maximum_sctype(np.uint8)
<type 'numpy.uint64'>
- >>> np.maximum_sctype(np.complex)
+ >>> np.maximum_sctype(complex)
<type 'numpy.complex192'>
>>> np.maximum_sctype(str)
@@ -684,9 +684,9 @@ def issubclass_(arg1, arg2):
Examples
--------
- >>> np.issubclass_(np.int32, np.int)
+ >>> np.issubclass_(np.int32, int)
True
- >>> np.issubclass_(np.int32, np.float)
+ >>> np.issubclass_(np.int32, float)
False
"""
@@ -717,9 +717,9 @@ def issubsctype(arg1, arg2):
--------
>>> np.issubsctype('S8', str)
True
- >>> np.issubsctype(np.array([1]), np.int)
+ >>> np.issubsctype(np.array([1]), int)
True
- >>> np.issubsctype(np.array([1]), np.float)
+ >>> np.issubsctype(np.array([1]), float)
False
"""
@@ -821,7 +821,7 @@ def sctype2char(sctype):
Examples
--------
- >>> for sctype in [np.int32, np.float, np.complex, np.string_, np.ndarray]:
+ >>> for sctype in [np.int32, float, complex, np.string_, np.ndarray]:
... print(np.sctype2char(sctype))
l
d
@@ -986,7 +986,7 @@ def find_common_type(array_types, scalar_types):
Examples
--------
- >>> np.find_common_type([], [np.int64, np.float32, np.complex])
+ >>> np.find_common_type([], [np.int64, np.float32, complex])
dtype('complex128')
>>> np.find_common_type([np.int64, np.float32], [])
dtype('float64')
@@ -1002,7 +1002,7 @@ def find_common_type(array_types, scalar_types):
Complex is of a different type, so it up-casts the float in the
`array_types` argument:
- >>> np.find_common_type([np.float32], [np.complex])
+ >>> np.find_common_type([np.float32], [complex])
dtype('complex128')
Type specifier strings are convertible to dtypes and can therefore
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 3df34a7b8..42871a77d 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -259,7 +259,7 @@ class TestNonCContiguousViewDeprecation(_DeprecationTestCase):
"""
def test_fortran_contiguous(self):
- self.assert_deprecated(np.ones((2,2)).T.view, args=(np.complex,))
+ self.assert_deprecated(np.ones((2,2)).T.view, args=(complex,))
self.assert_deprecated(np.ones((2,2)).T.view, args=(np.int8,))
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 06dd58591..6f6654d42 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -23,7 +23,7 @@ def assert_dtype_not_equal(a, b):
class TestBuiltin(object):
def test_run(self):
"""Only test hash runs at all."""
- for t in [np.int, np.float, np.complex, np.int32, np.str, np.object,
+ for t in [int, float, complex, np.int32, str, object,
np.unicode]:
dt = np.dtype(t)
hash(dt)
@@ -31,7 +31,7 @@ class TestBuiltin(object):
def test_dtype(self):
# Make sure equivalent byte order char hash the same (e.g. < and = on
# little endian)
- for t in [np.int, np.float]:
+ for t in [int, float]:
dt = np.dtype(t)
dt2 = dt.newbyteorder("<")
dt3 = dt.newbyteorder(">")
@@ -107,14 +107,14 @@ class TestBuiltin(object):
class TestRecord(object):
def test_equivalent_record(self):
"""Test whether equivalent record dtypes hash the same."""
- a = np.dtype([('yo', np.int)])
- b = np.dtype([('yo', np.int)])
+ a = np.dtype([('yo', int)])
+ b = np.dtype([('yo', int)])
assert_dtype_equal(a, b)
def test_different_names(self):
# In theory, they may hash the same (collision) ?
- a = np.dtype([('yo', np.int)])
- b = np.dtype([('ye', np.int)])
+ a = np.dtype([('yo', int)])
+ b = np.dtype([('ye', int)])
assert_dtype_not_equal(a, b)
def test_different_titles(self):
@@ -129,9 +129,9 @@ class TestRecord(object):
def test_mutate(self):
# Mutating a dtype should reset the cached hash value
- a = np.dtype([('yo', np.int)])
- b = np.dtype([('yo', np.int)])
- c = np.dtype([('ye', np.int)])
+ a = np.dtype([('yo', int)])
+ b = np.dtype([('yo', int)])
+ c = np.dtype([('ye', int)])
assert_dtype_equal(a, b)
assert_dtype_not_equal(a, c)
a.names = ['ye']
@@ -291,8 +291,8 @@ class TestRecord(object):
class TestSubarray(object):
def test_single_subarray(self):
- a = np.dtype((np.int, (2)))
- b = np.dtype((np.int, (2,)))
+ a = np.dtype((int, (2)))
+ b = np.dtype((int, (2,)))
assert_dtype_equal(a, b)
assert_equal(type(a.subdtype[1]), tuple)
@@ -300,29 +300,29 @@ class TestSubarray(object):
def test_equivalent_record(self):
"""Test whether equivalent subarray dtypes hash the same."""
- a = np.dtype((np.int, (2, 3)))
- b = np.dtype((np.int, (2, 3)))
+ a = np.dtype((int, (2, 3)))
+ b = np.dtype((int, (2, 3)))
assert_dtype_equal(a, b)
def test_nonequivalent_record(self):
"""Test whether different subarray dtypes hash differently."""
- a = np.dtype((np.int, (2, 3)))
- b = np.dtype((np.int, (3, 2)))
+ a = np.dtype((int, (2, 3)))
+ b = np.dtype((int, (3, 2)))
assert_dtype_not_equal(a, b)
- a = np.dtype((np.int, (2, 3)))
- b = np.dtype((np.int, (2, 2)))
+ a = np.dtype((int, (2, 3)))
+ b = np.dtype((int, (2, 2)))
assert_dtype_not_equal(a, b)
- a = np.dtype((np.int, (1, 2, 3)))
- b = np.dtype((np.int, (1, 2)))
+ a = np.dtype((int, (1, 2, 3)))
+ b = np.dtype((int, (1, 2)))
assert_dtype_not_equal(a, b)
def test_shape_equal(self):
"""Test some data types that are equal"""
assert_dtype_equal(np.dtype('f8'), np.dtype(('f8', tuple())))
assert_dtype_equal(np.dtype('f8'), np.dtype(('f8', 1)))
- assert_dtype_equal(np.dtype((np.int, 2)), np.dtype((np.int, (2,))))
+ assert_dtype_equal(np.dtype((int, 2)), np.dtype((int, (2,))))
assert_dtype_equal(np.dtype(('<f4', (3, 2))), np.dtype(('<f4', (3, 2))))
d = ([('a', 'f4', (1, 2)), ('b', 'f8', (3, 1))], (3, 2))
assert_dtype_equal(np.dtype(d), np.dtype(d))
@@ -421,15 +421,15 @@ class TestMonsterType(object):
def test1(self):
simple1 = np.dtype({'names': ['r', 'b'], 'formats': ['u1', 'u1'],
'titles': ['Red pixel', 'Blue pixel']})
- a = np.dtype([('yo', np.int), ('ye', simple1),
- ('yi', np.dtype((np.int, (3, 2))))])
- b = np.dtype([('yo', np.int), ('ye', simple1),
- ('yi', np.dtype((np.int, (3, 2))))])
+ a = np.dtype([('yo', int), ('ye', simple1),
+ ('yi', np.dtype((int, (3, 2))))])
+ b = np.dtype([('yo', int), ('ye', simple1),
+ ('yi', np.dtype((int, (3, 2))))])
assert_dtype_equal(a, b)
- c = np.dtype([('yo', np.int), ('ye', simple1),
+ c = np.dtype([('yo', int), ('ye', simple1),
('yi', np.dtype((a, (3, 2))))])
- d = np.dtype([('yo', np.int), ('ye', simple1),
+ d = np.dtype([('yo', int), ('ye', simple1),
('yi', np.dtype((a, (3, 2))))])
assert_dtype_equal(c, d)
@@ -641,8 +641,8 @@ class TestPickling(object):
assert_equal(x[0], y[0])
def test_builtin(self):
- for t in [np.int, np.float, np.complex, np.int32, np.str, np.object,
- np.unicode, np.bool]:
+ for t in [int, float, complex, np.int32, str, object,
+ np.unicode, bool]:
self.check_pickling(np.dtype(t))
def test_structured(self):
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
index 9678f0360..813cf9572 100644
--- a/numpy/core/tests/test_half.py
+++ b/numpy/core/tests/test_half.py
@@ -65,7 +65,7 @@ class TestHalf(object):
# Check the range for which all integers can be represented
i_int = np.arange(-2048, 2049)
i_f16 = np.array(i_int, dtype=float16)
- j = np.array(i_f16, dtype=np.int)
+ j = np.array(i_f16, dtype=int)
assert_equal(i_int, j)
def test_nans_infs(self):
diff --git a/numpy/core/tests/test_item_selection.py b/numpy/core/tests/test_item_selection.py
index 28088974f..a0a458ca5 100644
--- a/numpy/core/tests/test_item_selection.py
+++ b/numpy/core/tests/test_item_selection.py
@@ -24,7 +24,7 @@ class TestTake(object):
# Currently all types but object, use the same function generation.
# So it should not be necessary to test all. However test also a non
# refcounted struct on top of object.
- types = np.int, np.object, np.dtype([('', 'i', 2)])
+ types = int, object, np.dtype([('', 'i', 2)])
for t in types:
# ta works, even if the array may be odd if buffer interface is used
ta = np.array(a if np.issubdtype(t, np.number) else a_str, dtype=t)
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 21f40566e..eb9fa25cf 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -297,7 +297,7 @@ class TestArrayConstruction(object):
assert_equal(r[0], [d, d + 1])
assert_equal(r[1], d + 2)
- tgt = np.ones((2, 3), dtype=np.bool)
+ tgt = np.ones((2, 3), dtype=bool)
tgt[0, 2] = False
tgt[1, 0:2] = False
r = np.array([[True, True, False], [False, False, True]])
@@ -759,20 +759,20 @@ class TestCreation(object):
str(d)
def test_sequence_non_homogenous(self):
- assert_equal(np.array([4, 2**80]).dtype, np.object)
- assert_equal(np.array([4, 2**80, 4]).dtype, np.object)
- assert_equal(np.array([2**80, 4]).dtype, np.object)
- assert_equal(np.array([2**80] * 3).dtype, np.object)
- assert_equal(np.array([[1, 1],[1j, 1j]]).dtype, np.complex)
- assert_equal(np.array([[1j, 1j],[1, 1]]).dtype, np.complex)
- assert_equal(np.array([[1, 1, 1],[1, 1j, 1.], [1, 1, 1]]).dtype, np.complex)
+ assert_equal(np.array([4, 2**80]).dtype, object)
+ assert_equal(np.array([4, 2**80, 4]).dtype, object)
+ assert_equal(np.array([2**80, 4]).dtype, object)
+ assert_equal(np.array([2**80] * 3).dtype, object)
+ assert_equal(np.array([[1, 1],[1j, 1j]]).dtype, complex)
+ assert_equal(np.array([[1j, 1j],[1, 1]]).dtype, complex)
+ assert_equal(np.array([[1, 1, 1],[1, 1j, 1.], [1, 1, 1]]).dtype, complex)
@dec.skipif(sys.version_info[0] >= 3)
def test_sequence_long(self):
assert_equal(np.array([long(4), long(4)]).dtype, np.long)
- assert_equal(np.array([long(4), 2**80]).dtype, np.object)
- assert_equal(np.array([long(4), 2**80, long(4)]).dtype, np.object)
- assert_equal(np.array([2**80, long(4)]).dtype, np.object)
+ assert_equal(np.array([long(4), 2**80]).dtype, object)
+ assert_equal(np.array([long(4), 2**80, long(4)]).dtype, object)
+ assert_equal(np.array([2**80, long(4)]).dtype, object)
def test_non_sequence_sequence(self):
"""Should not segfault.
@@ -876,7 +876,7 @@ class TestStructured(object):
# multi-dimensional field types work properly
a = np.rec.fromrecords(
[([1, 2, 3], 'a', [[1, 2], [3, 4]]), ([3, 3, 3], 'b', [[0, 0], [0, 0]])],
- dtype=[('a', ('f4', 3)), ('b', np.object), ('c', ('i4', (2, 2)))])
+ dtype=[('a', ('f4', 3)), ('b', object), ('c', ('i4', (2, 2)))])
b = a.copy()
assert_equal(a == b, [True, True])
assert_equal(a != b, [False, False])
@@ -1109,7 +1109,7 @@ class TestBool(object):
assert_(np.array(True)[()] is a1)
def test_sum(self):
- d = np.ones(101, dtype=np.bool)
+ d = np.ones(101, dtype=bool)
assert_equal(d.sum(), d.size)
assert_equal(d[::2].sum(), d[::2].size)
assert_equal(d[::-2].sum(), d[::-2].size)
@@ -1123,7 +1123,7 @@ class TestBool(object):
powers = [2 ** i for i in range(length)]
for i in range(2**power):
l = [(i & x) != 0 for x in powers]
- a = np.array(l, dtype=np.bool)
+ a = np.array(l, dtype=bool)
c = builtins.sum(l)
assert_equal(np.count_nonzero(a), c)
av = a.view(np.uint8)
@@ -1148,10 +1148,10 @@ class TestBool(object):
def test_count_nonzero_unaligned(self):
# prevent mistakes as e.g. gh-4060
for o in range(7):
- a = np.zeros((18,), dtype=np.bool)[o+1:]
+ a = np.zeros((18,), dtype=bool)[o+1:]
a[:o] = True
assert_equal(np.count_nonzero(a), builtins.sum(a.tolist()))
- a = np.ones((18,), dtype=np.bool)[o+1:]
+ a = np.ones((18,), dtype=bool)[o+1:]
a[:o] = False
assert_equal(np.count_nonzero(a), builtins.sum(a.tolist()))
@@ -1381,7 +1381,7 @@ class TestMethods(object):
assert_equal(c, a, msg)
# test object array sorts.
- a = np.empty((101,), dtype=np.object)
+ a = np.empty((101,), dtype=object)
a[:] = list(range(101))
b = a[::-1]
for kind in ['q', 'h', 'm']:
@@ -1627,7 +1627,7 @@ class TestMethods(object):
assert_equal(b.copy().argsort(kind=kind), rr, msg)
# test object array argsorts.
- a = np.empty((101,), dtype=np.object)
+ a = np.empty((101,), dtype=object)
a[:] = list(range(101))
b = a[::-1]
r = np.arange(101)
@@ -1694,7 +1694,7 @@ class TestMethods(object):
a = np.zeros(100)
assert_equal(a.argsort(kind='m'), r)
# complex
- a = np.zeros(100, dtype=np.complex)
+ a = np.zeros(100, dtype=complex)
assert_equal(a.argsort(kind='m'), r)
# string
a = np.array(['aaaaaaaaa' for i in range(100)])
@@ -3180,7 +3180,7 @@ class TestTemporaryElide(object):
# only triggers elision code path in debug mode as triggering it in
# normal mode needs 256kb large matching dimension, so a lot of memory
d = np.ones((2000, 1), dtype=int)
- b = np.ones((2000), dtype=np.bool)
+ b = np.ones((2000), dtype=bool)
r = (1 - d) + b
assert_equal(r, 1)
assert_equal(r.shape, (2000, 2000))
@@ -3937,7 +3937,7 @@ class TestIO(object):
def setup(self):
shape = (2, 4, 3)
rand = np.random.random
- self.x = rand(shape) + rand(shape).astype(np.complex)*1j
+ self.x = rand(shape) + rand(shape).astype(complex)*1j
self.x[0,:, 1] = [np.nan, np.inf, -np.inf, np.nan]
self.dtype = self.x.dtype
self.tempdir = tempfile.mkdtemp()
@@ -4253,7 +4253,7 @@ class TestFromBuffer(object):
def test_ip_basic(self):
for byteorder in ['<', '>']:
- for dtype in [float, int, np.complex]:
+ for dtype in [float, int, complex]:
dt = np.dtype(dtype).newbyteorder(byteorder)
x = (np.random.random((4, 7))*5).astype(dt)
buf = x.tobytes()
@@ -4835,7 +4835,7 @@ class TestVdot(object):
assert_equal(np.vdot(b, b), 3)
# test boolean
- b = np.eye(3, dtype=np.bool)
+ b = np.eye(3, dtype=bool)
res = np.vdot(b, b)
assert_(np.isscalar(res))
assert_equal(np.vdot(b, b), True)
@@ -5350,19 +5350,19 @@ class TestMatmul(MatmulCommon):
matmul = np.matmul
def test_out_arg(self):
- a = np.ones((2, 2), dtype=np.float)
- b = np.ones((2, 2), dtype=np.float)
- tgt = np.full((2,2), 2, dtype=np.float)
+ a = np.ones((2, 2), dtype=float)
+ b = np.ones((2, 2), dtype=float)
+ tgt = np.full((2,2), 2, dtype=float)
# test as positional argument
msg = "out positional argument"
- out = np.zeros((2, 2), dtype=np.float)
+ out = np.zeros((2, 2), dtype=float)
self.matmul(a, b, out)
assert_array_equal(out, tgt, err_msg=msg)
# test as keyword argument
msg = "out keyword argument"
- out = np.zeros((2, 2), dtype=np.float)
+ out = np.zeros((2, 2), dtype=float)
self.matmul(a, b, out=out)
assert_array_equal(out, tgt, err_msg=msg)
@@ -5385,7 +5385,7 @@ class TestMatmul(MatmulCommon):
# test out non-contiguous
# msg = "out argument with non-contiguous layout"
- # c = np.zeros((2, 2, 2), dtype=np.float)
+ # c = np.zeros((2, 2, 2), dtype=float)
# self.matmul(a, b, out=c[..., 0])
# assert_array_equal(c, tgt, err_msg=msg)
@@ -5649,7 +5649,7 @@ class TestNeighborhoodIter(object):
assert_array_equal(l, r)
def test_simple2d(self):
- self._test_simple2d(np.float)
+ self._test_simple2d(float)
def test_simple2d_object(self):
self._test_simple2d(Decimal)
@@ -5665,7 +5665,7 @@ class TestNeighborhoodIter(object):
assert_array_equal(l, r)
def test_mirror2d(self):
- self._test_mirror2d(np.float)
+ self._test_mirror2d(float)
def test_mirror2d_object(self):
self._test_mirror2d(Decimal)
@@ -5687,7 +5687,7 @@ class TestNeighborhoodIter(object):
assert_array_equal(l, r)
def test_simple_float(self):
- self._test_simple(np.float)
+ self._test_simple(float)
def test_simple_object(self):
self._test_simple(Decimal)
@@ -5702,7 +5702,7 @@ class TestNeighborhoodIter(object):
assert_array_equal(l, r)
def test_mirror(self):
- self._test_mirror(np.float)
+ self._test_mirror(float)
def test_mirror_object(self):
self._test_mirror(Decimal)
@@ -5716,7 +5716,7 @@ class TestNeighborhoodIter(object):
assert_array_equal(l, r)
def test_circular(self):
- self._test_circular(np.float)
+ self._test_circular(float)
def test_circular_object(self):
self._test_circular(Decimal)
@@ -6530,10 +6530,10 @@ class TestConversion(object):
class TestWhere(object):
def test_basic(self):
- dts = [np.bool, np.int16, np.int32, np.int64, np.double, np.complex128,
+ dts = [bool, np.int16, np.int32, np.int64, np.double, np.complex128,
np.longdouble, np.clongdouble]
for dt in dts:
- c = np.ones(53, dtype=np.bool)
+ c = np.ones(53, dtype=bool)
assert_equal(np.where( c, dt(0), dt(1)), dt(0))
assert_equal(np.where(~c, dt(0), dt(1)), dt(1))
assert_equal(np.where(True, dt(0), dt(1)), dt(0))
@@ -6625,7 +6625,7 @@ class TestWhere(object):
assert_equal(np.where(c, a, b), r)
# non bool mask
- c = c.astype(np.int)
+ c = c.astype(int)
c[c != 0] = 34242324
assert_equal(np.where(c, a, b), r)
# invert
@@ -6841,20 +6841,20 @@ class TestArrayPriority(object):
class TestBytestringArrayNonzero(object):
def test_empty_bstring_array_is_falsey(self):
- assert_(not np.array([''], dtype=np.str))
+ assert_(not np.array([''], dtype=str))
def test_whitespace_bstring_array_is_falsey(self):
- a = np.array(['spam'], dtype=np.str)
+ a = np.array(['spam'], dtype=str)
a[0] = ' \0\0'
assert_(not a)
def test_all_null_bstring_array_is_falsey(self):
- a = np.array(['spam'], dtype=np.str)
+ a = np.array(['spam'], dtype=str)
a[0] = '\0\0\0\0'
assert_(not a)
def test_null_inside_bstring_array_is_truthy(self):
- a = np.array(['spam'], dtype=np.str)
+ a = np.array(['spam'], dtype=str)
a[0] = ' \0 \0'
assert_(a)
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py
index 1bcc13bdc..885dcb56f 100644
--- a/numpy/core/tests/test_nditer.py
+++ b/numpy/core/tests/test_nditer.py
@@ -2145,7 +2145,7 @@ def test_iter_buffered_reduce_reuse():
op_flags = [('readonly',), ('readwrite', 'allocate')]
op_axes_list = [[(0, 1, 2), (0, 1, -1)], [(0, 1, 2), (0, -1, -1)]]
# wrong dtype to force buffering
- op_dtypes = [np.float, a.dtype]
+ op_dtypes = [float, a.dtype]
def get_params():
for xs in range(-3**2, 3**2 + 1):
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index d597c9260..ce6712ed2 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -244,9 +244,9 @@ class TestBoolScalar(object):
class TestBoolArray(object):
def setup(self):
# offset for simd tests
- self.t = np.array([True] * 41, dtype=np.bool)[1::]
- self.f = np.array([False] * 41, dtype=np.bool)[1::]
- self.o = np.array([False] * 42, dtype=np.bool)[2::]
+ self.t = np.array([True] * 41, dtype=bool)[1::]
+ self.f = np.array([False] * 41, dtype=bool)[1::]
+ self.o = np.array([False] * 42, dtype=bool)[2::]
self.nm = self.f.copy()
self.im = self.t.copy()
self.nm[3] = True
@@ -265,19 +265,19 @@ class TestBoolArray(object):
assert_(not self.im.all())
# check bad element in all positions
for i in range(256 - 7):
- d = np.array([False] * 256, dtype=np.bool)[7::]
+ d = np.array([False] * 256, dtype=bool)[7::]
d[i] = True
assert_(np.any(d))
- e = np.array([True] * 256, dtype=np.bool)[7::]
+ e = np.array([True] * 256, dtype=bool)[7::]
e[i] = False
assert_(not np.all(e))
assert_array_equal(e, ~d)
# big array test for blocked libc loops
for i in list(range(9, 6000, 507)) + [7764, 90021, -10]:
- d = np.array([False] * 100043, dtype=np.bool)
+ d = np.array([False] * 100043, dtype=bool)
d[i] = True
assert_(np.any(d), msg="%r" % i)
- e = np.array([True] * 100043, dtype=np.bool)
+ e = np.array([True] * 100043, dtype=bool)
e[i] = False
assert_(not np.all(e), msg="%r" % i)
@@ -331,9 +331,9 @@ class TestBoolArray(object):
class TestBoolCmp(object):
def setup(self):
self.f = np.ones(256, dtype=np.float32)
- self.ef = np.ones(self.f.size, dtype=np.bool)
+ self.ef = np.ones(self.f.size, dtype=bool)
self.d = np.ones(128, dtype=np.float64)
- self.ed = np.ones(self.d.size, dtype=np.bool)
+ self.ed = np.ones(self.d.size, dtype=bool)
# generate values for all permutation of 256bit simd vectors
s = 0
for i in range(32):
@@ -800,8 +800,8 @@ class TestTypes(object):
def test_can_cast(self):
assert_(np.can_cast(np.int32, np.int64))
- assert_(np.can_cast(np.float64, np.complex))
- assert_(not np.can_cast(np.complex, np.float))
+ assert_(np.can_cast(np.float64, complex))
+ assert_(not np.can_cast(complex, float))
assert_(np.can_cast('i8', 'f8'))
assert_(not np.can_cast('i8', 'f4'))
@@ -981,11 +981,11 @@ class TestNonzero(object):
def test_sparse(self):
# test special sparse condition boolean code path
for i in range(20):
- c = np.zeros(200, dtype=np.bool)
+ c = np.zeros(200, dtype=bool)
c[i::20] = True
assert_equal(np.nonzero(c)[0], np.arange(i, 200 + i, 20))
- c = np.zeros(400, dtype=np.bool)
+ c = np.zeros(400, dtype=bool)
c[10 + i:20 + i] = True
c[20 + i*2] = True
assert_equal(np.nonzero(c)[0],
@@ -1095,7 +1095,7 @@ class TestNonzero(object):
rng = np.random.RandomState(1234)
m = rng.randint(-100, 100, size=size)
- n = m.astype(np.object)
+ n = m.astype(object)
for length in range(len(axis)):
for combo in combinations(axis, length):
@@ -1386,7 +1386,7 @@ class TestClip(object):
# Address Issue gh-5354 for clipping complex arrays
# Test native complex input without explicit min/max
# ie, either min=None or max=None
- a = np.ones(10, dtype=np.complex)
+ a = np.ones(10, dtype=complex)
m = a.min()
M = a.max()
am = self.fastclip(a, m, None)
@@ -2185,7 +2185,7 @@ class TestCorrelate(object):
-102., -54., -19.], dtype=dt)
def test_float(self):
- self._setup(np.float)
+ self._setup(float)
z = np.correlate(self.x, self.y, 'full')
assert_array_almost_equal(z, self.z1)
z = np.correlate(self.x, self.y[:-1], 'full')
@@ -2214,9 +2214,9 @@ class TestCorrelate(object):
assert_array_equal(k, np.ones(3))
def test_complex(self):
- x = np.array([1, 2, 3, 4+1j], dtype=np.complex)
- y = np.array([-1, -2j, 3+1j], dtype=np.complex)
- r_z = np.array([3-1j, 6, 8+1j, 11+5j, -5+8j, -4-1j], dtype=np.complex)
+ x = np.array([1, 2, 3, 4+1j], dtype=complex)
+ y = np.array([-1, -2j, 3+1j], dtype=complex)
+ r_z = np.array([3-1j, 6, 8+1j, 11+5j, -5+8j, -4-1j], dtype=complex)
r_z = r_z[::-1].conjugate()
z = np.correlate(y, x, mode='full')
assert_array_almost_equal(z, r_z)
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py
index b1ce12f56..305258d6f 100644
--- a/numpy/core/tests/test_print.py
+++ b/numpy/core/tests/test_print.py
@@ -35,7 +35,7 @@ def test_float_types():
""" Check formatting.
This is only for the str function, and only for simple types.
- The precision of np.float and np.longdouble aren't the same as the
+ The precision of np.float32 and np.longdouble aren't the same as the
python float precision.
"""
@@ -51,7 +51,7 @@ def test_nan_inf_float():
""" Check formatting of nan & inf.
This is only for the str function, and only for simple types.
- The precision of np.float and np.longdouble aren't the same as the
+ The precision of np.float32 and np.longdouble aren't the same as the
python float precision.
"""
@@ -79,7 +79,7 @@ def test_complex_types():
"""Check formatting of complex types.
This is only for the str function, and only for simple types.
- The precision of np.float and np.longdouble aren't the same as the
+ The precision of np.float32 and np.longdouble aren't the same as the
python float precision.
"""
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index f9f143249..d7714132b 100644
--- a/numpy/core/tests/test_records.py
+++ b/numpy/core/tests/test_records.py
@@ -29,7 +29,7 @@ class TestFromrecords(object):
def test_fromrecords_0len(self):
""" Verify fromrecords works with a 0-length input """
- dtype = [('a', np.float), ('b', np.float)]
+ dtype = [('a', float), ('b', float)]
r = np.rec.fromrecords([], dtype=dtype)
assert_equal(r.shape, (0,))
@@ -235,13 +235,13 @@ class TestFromrecords(object):
def test_fromrecords_with_explicit_dtype(self):
a = np.rec.fromrecords([(1, 'a'), (2, 'bbb')],
- dtype=[('a', int), ('b', np.object)])
+ dtype=[('a', int), ('b', object)])
assert_equal(a.a, [1, 2])
assert_equal(a[0].a, 1)
assert_equal(a.b, ['a', 'bbb'])
assert_equal(a[-1].b, 'bbb')
#
- ndtype = np.dtype([('a', int), ('b', np.object)])
+ ndtype = np.dtype([('a', int), ('b', object)])
a = np.rec.fromrecords([(1, 'a'), (2, 'bbb')], dtype=ndtype)
assert_equal(a.a, [1, 2])
assert_equal(a[0].a, 1)
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index a802e6af6..c3ff6fa97 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -446,7 +446,7 @@ class TestRegression(object):
def test_pickle_dtype(self, level=rlevel):
# Ticket #251
- pickle.dumps(np.float)
+ pickle.dumps(float)
def test_swap_real(self, level=rlevel):
# Ticket #265
@@ -1360,7 +1360,7 @@ class TestRegression(object):
a = np.ones(100, dtype=np.int8)
b = np.ones(100, dtype=np.int32)
i = np.lexsort((a[::-1], b))
- assert_equal(i, np.arange(100, dtype=np.int))
+ assert_equal(i, np.arange(100, dtype=int))
def test_object_array_to_fixed_string(self):
# Ticket #1235.
@@ -1471,7 +1471,7 @@ class TestRegression(object):
min //= -1
with np.errstate(divide="ignore"):
- for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
+ for t in (np.int8, np.int16, np.int32, np.int64, int, np.long):
test_type(t)
def test_buffer_hashlib(self):
@@ -1563,9 +1563,9 @@ class TestRegression(object):
@dec.skipif(not HAS_REFCOUNT, "python has no sys.getrefcount")
def test_take_refcount(self):
# ticket #939
- a = np.arange(16, dtype=np.float)
+ a = np.arange(16, dtype=float)
a.shape = (4, 4)
- lut = np.ones((5 + 3, 4), np.float)
+ lut = np.ones((5 + 3, 4), float)
rgba = np.empty(shape=a.shape + (4,), dtype=lut.dtype)
c1 = sys.getrefcount(rgba)
try:
@@ -2173,7 +2173,7 @@ class TestRegression(object):
# gh-6250
recordtype = np.dtype([('a', np.float64),
('b', np.int32),
- ('d', (np.str, 5))])
+ ('d', (str, 5))])
# Simple case
a = np.zeros(2, dtype=recordtype)
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index d1cc9eed6..d2e326d24 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -126,7 +126,7 @@ class TestPower(object):
def test_integers_to_negative_integer_power(self):
# Note that the combination of uint64 with a signed integer
- # has common type np.float. The other combinations should all
+ # has common type np.float64. The other combinations should all
# raise a ValueError for integer ** negative integer.
exp = [np.array(-1, dt)[()] for dt in 'bhilq']
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 3a0d8e0ae..57e0ec272 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -17,7 +17,7 @@ from numpy.testing import (
class TestUfuncKwargs(object):
def test_kwarg_exact(self):
assert_raises(TypeError, np.add, 1, 2, castingx='safe')
- assert_raises(TypeError, np.add, 1, 2, dtypex=np.int)
+ assert_raises(TypeError, np.add, 1, 2, dtypex=int)
assert_raises(TypeError, np.add, 1, 2, extobjx=[4096])
assert_raises(TypeError, np.add, 1, 2, outx=None)
assert_raises(TypeError, np.add, 1, 2, sigx='ii->i')
@@ -31,9 +31,9 @@ class TestUfuncKwargs(object):
def test_sig_dtype(self):
assert_raises(RuntimeError, np.add, 1, 2, sig='ii->i',
- dtype=np.int)
+ dtype=int)
assert_raises(RuntimeError, np.add, 1, 2, signature='ii->i',
- dtype=np.int)
+ dtype=int)
class TestUfunc(object):
@@ -174,22 +174,22 @@ class TestUfunc(object):
# check unary PyUFunc_O_O
msg = "PyUFunc_O_O"
- x = np.ones(10, dtype=np.object)[0::2]
+ x = np.ones(10, dtype=object)[0::2]
assert_(np.all(np.abs(x) == 1), msg)
# check unary PyUFunc_O_O_method
msg = "PyUFunc_O_O_method"
- x = np.zeros(10, dtype=np.object)[0::2]
+ x = np.zeros(10, dtype=object)[0::2]
for i in range(len(x)):
x[i] = foo()
assert_(np.all(np.conjugate(x) == True), msg)
# check binary PyUFunc_OO_O
msg = "PyUFunc_OO_O"
- x = np.ones(10, dtype=np.object)[0::2]
+ x = np.ones(10, dtype=object)[0::2]
assert_(np.all(np.add(x, x) == 2), msg)
# check binary PyUFunc_OO_O_method
msg = "PyUFunc_OO_O_method"
- x = np.zeros(10, dtype=np.object)[0::2]
+ x = np.zeros(10, dtype=object)[0::2]
for i in range(len(x)):
x[i] = foo()
assert_(np.all(np.logical_xor(x, x)), msg)
@@ -437,7 +437,7 @@ class TestUfunc(object):
assert_almost_equal((a / 10.).sum() - a.size / 10., 0, 13)
def test_sum(self):
- for dt in (np.int, np.float16, np.float32, np.float64, np.longdouble):
+ for dt in (int, np.float16, np.float32, np.float64, np.longdouble):
for v in (0, 1, 2, 7, 8, 9, 15, 16, 19, 127,
128, 1024, 1235):
tgt = dt(v * (v + 1) / 2)
@@ -679,7 +679,7 @@ class TestUfunc(object):
assert_equal(ref, True, err_msg="reference check")
def test_euclidean_pdist(self):
- a = np.arange(12, dtype=np.float).reshape(4, 3)
+ a = np.arange(12, dtype=float).reshape(4, 3)
out = np.empty((a.shape[0] * (a.shape[0] - 1) // 2,), dtype=a.dtype)
umt.euclidean_pdist(a, out)
b = np.sqrt(np.sum((a[:, None] - a)**2, axis=-1))
@@ -1254,9 +1254,9 @@ class TestUfunc(object):
assert_array_equal(values, [1, 8, 6, 4])
# Test exception thrown
- values = np.array(['a', 1], dtype=np.object)
+ values = np.array(['a', 1], dtype=object)
assert_raises(TypeError, np.add.at, values, [0, 1], 1)
- assert_array_equal(values, np.array(['a', 1], dtype=np.object))
+ assert_array_equal(values, np.array(['a', 1], dtype=object))
# Test multiple output ufuncs raise error, gh-5665
assert_raises(ValueError, np.modf.at, np.arange(10), [1])
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 714af5b65..5787a5183 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -897,22 +897,22 @@ class TestMaximum(_FilterInvalids):
# fail if cmp is used instead of rich compare.
# Failure cannot be guaranteed.
for i in range(1):
- x = np.array(float('nan'), np.object)
+ x = np.array(float('nan'), object)
y = 1.0
- z = np.array(float('nan'), np.object)
+ z = np.array(float('nan'), object)
assert_(np.maximum(x, y) == 1.0)
assert_(np.maximum(z, y) == 1.0)
def test_complex_nans(self):
nan = np.nan
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
- arg1 = np.array([0, cnan, cnan], dtype=np.complex)
- arg2 = np.array([cnan, 0, cnan], dtype=np.complex)
- out = np.array([nan, nan, nan], dtype=np.complex)
+ arg1 = np.array([0, cnan, cnan], dtype=complex)
+ arg2 = np.array([cnan, 0, cnan], dtype=complex)
+ out = np.array([nan, nan, nan], dtype=complex)
assert_equal(np.maximum(arg1, arg2), out)
def test_object_array(self):
- arg1 = np.arange(5, dtype=np.object)
+ arg1 = np.arange(5, dtype=object)
arg2 = arg1 + 1
assert_equal(np.maximum(arg1, arg2), arg2)
@@ -955,22 +955,22 @@ class TestMinimum(_FilterInvalids):
# fail if cmp is used instead of rich compare.
# Failure cannot be guaranteed.
for i in range(1):
- x = np.array(float('nan'), np.object)
+ x = np.array(float('nan'), object)
y = 1.0
- z = np.array(float('nan'), np.object)
+ z = np.array(float('nan'), object)
assert_(np.minimum(x, y) == 1.0)
assert_(np.minimum(z, y) == 1.0)
def test_complex_nans(self):
nan = np.nan
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
- arg1 = np.array([0, cnan, cnan], dtype=np.complex)
- arg2 = np.array([cnan, 0, cnan], dtype=np.complex)
- out = np.array([nan, nan, nan], dtype=np.complex)
+ arg1 = np.array([0, cnan, cnan], dtype=complex)
+ arg2 = np.array([cnan, 0, cnan], dtype=complex)
+ out = np.array([nan, nan, nan], dtype=complex)
assert_equal(np.minimum(arg1, arg2), out)
def test_object_array(self):
- arg1 = np.arange(5, dtype=np.object)
+ arg1 = np.arange(5, dtype=object)
arg2 = arg1 + 1
assert_equal(np.minimum(arg1, arg2), arg1)
@@ -1011,9 +1011,9 @@ class TestFmax(_FilterInvalids):
def test_complex_nans(self):
nan = np.nan
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
- arg1 = np.array([0, cnan, cnan], dtype=np.complex)
- arg2 = np.array([cnan, 0, cnan], dtype=np.complex)
- out = np.array([0, 0, nan], dtype=np.complex)
+ arg1 = np.array([0, cnan, cnan], dtype=complex)
+ arg2 = np.array([cnan, 0, cnan], dtype=complex)
+ out = np.array([0, 0, nan], dtype=complex)
assert_equal(np.fmax(arg1, arg2), out)
@@ -1053,9 +1053,9 @@ class TestFmin(_FilterInvalids):
def test_complex_nans(self):
nan = np.nan
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
- arg1 = np.array([0, cnan, cnan], dtype=np.complex)
- arg2 = np.array([cnan, 0, cnan], dtype=np.complex)
- out = np.array([0, 0, nan], dtype=np.complex)
+ arg1 = np.array([0, cnan, cnan], dtype=complex)
+ arg2 = np.array([cnan, 0, cnan], dtype=complex)
+ out = np.array([0, 0, nan], dtype=complex)
assert_equal(np.fmin(arg1, arg2), out)
@@ -1210,7 +1210,7 @@ class TestBitwiseUFuncs(object):
class TestInt(object):
def test_logical_not(self):
x = np.ones(10, dtype=np.int16)
- o = np.ones(10 * 2, dtype=np.bool)
+ o = np.ones(10 * 2, dtype=bool)
tgt = o.copy()
tgt[::2] = False
os = o[::2]
@@ -1274,7 +1274,7 @@ class TestSign(object):
# In reference to github issue #6229
foo = np.array([-.1, 0, .1])
- a = np.sign(foo.astype(np.object))
+ a = np.sign(foo.astype(object))
b = np.sign(foo)
assert_array_equal(a, b)
@@ -1283,7 +1283,7 @@ class TestSign(object):
# In reference to github issue #6229
def test_nan():
foo = np.array([np.nan])
- a = np.sign(foo.astype(np.object))
+ a = np.sign(foo.astype(object))
assert_raises(TypeError, test_nan)
@@ -2210,7 +2210,7 @@ class TestComplexFunctions(object):
else:
x = .5
fr = f(x)
- fz = f(np.complex(x))
+ fz = f(complex(x))
assert_almost_equal(fz.real, fr, err_msg='real part %s' % f)
assert_almost_equal(fz.imag, 0., err_msg='imag part %s' % f)
@@ -2279,7 +2279,7 @@ class TestComplexFunctions(object):
points = [-1-1j, -1+1j, +1-1j, +1+1j]
name_map = {'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan',
'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'}
- atol = 4*np.finfo(np.complex).eps
+ atol = 4*np.finfo(complex).eps
for func in self.funcs:
fname = func.__name__.split('.')[-1]
cname = name_map.get(fname, fname)
@@ -2419,7 +2419,7 @@ class TestSubclass(object):
assert_equal(a+a, a)
def _check_branch_cut(f, x0, dx, re_sign=1, im_sign=-1, sig_zero_ok=False,
- dtype=np.complex):
+ dtype=complex):
"""
Check for a branch cut in a function.
diff --git a/numpy/core/tests/test_umath_complex.py b/numpy/core/tests/test_umath_complex.py
index eac22b884..fb3b6577c 100644
--- a/numpy/core/tests/test_umath_complex.py
+++ b/numpy/core/tests/test_umath_complex.py
@@ -38,7 +38,7 @@ class TestCexp(object):
yield check, f, 1, 0, np.exp(1), 0, False
yield check, f, 0, 1, np.cos(1), np.sin(1), False
- ref = np.exp(1) * np.complex(np.cos(1), np.sin(1))
+ ref = np.exp(1) * complex(np.cos(1), np.sin(1))
yield check, f, 1, 1, ref.real, ref.imag, False
@platform_skip
@@ -73,7 +73,7 @@ class TestCexp(object):
def _check_ninf_inf(dummy):
msgform = "cexp(-inf, inf) is (%f, %f), expected (+-0, +-0)"
with np.errstate(invalid='ignore'):
- z = f(np.array(np.complex(-np.inf, np.inf)))
+ z = f(np.array(complex(-np.inf, np.inf)))
if z.real != 0 or z.imag != 0:
raise AssertionError(msgform % (z.real, z.imag))
@@ -83,7 +83,7 @@ class TestCexp(object):
def _check_inf_inf(dummy):
msgform = "cexp(inf, inf) is (%f, %f), expected (+-inf, nan)"
with np.errstate(invalid='ignore'):
- z = f(np.array(np.complex(np.inf, np.inf)))
+ z = f(np.array(complex(np.inf, np.inf)))
if not np.isinf(z.real) or not np.isnan(z.imag):
raise AssertionError(msgform % (z.real, z.imag))
@@ -93,7 +93,7 @@ class TestCexp(object):
def _check_ninf_nan(dummy):
msgform = "cexp(-inf, nan) is (%f, %f), expected (+-0, +-0)"
with np.errstate(invalid='ignore'):
- z = f(np.array(np.complex(-np.inf, np.nan)))
+ z = f(np.array(complex(-np.inf, np.nan)))
if z.real != 0 or z.imag != 0:
raise AssertionError(msgform % (z.real, z.imag))
@@ -103,7 +103,7 @@ class TestCexp(object):
def _check_inf_nan(dummy):
msgform = "cexp(-inf, nan) is (%f, %f), expected (+-inf, nan)"
with np.errstate(invalid='ignore'):
- z = f(np.array(np.complex(np.inf, np.nan)))
+ z = f(np.array(complex(np.inf, np.nan)))
if not np.isinf(z.real) or not np.isnan(z.imag):
raise AssertionError(msgform % (z.real, z.imag))
@@ -150,8 +150,8 @@ class TestClog(object):
# clog(-0 + i0) returns -inf + i pi and raises the 'divide-by-zero'
# floating-point exception.
with np.errstate(divide='raise'):
- x = np.array([np.NZERO], dtype=np.complex)
- y = np.complex(-np.inf, np.pi)
+ x = np.array([np.NZERO], dtype=complex)
+ y = complex(-np.inf, np.pi)
assert_raises(FloatingPointError, np.log, x)
with np.errstate(divide='ignore'):
assert_almost_equal(np.log(x), y)
@@ -162,8 +162,8 @@ class TestClog(object):
# clog(+0 + i0) returns -inf + i0 and raises the 'divide-by-zero'
# floating-point exception.
with np.errstate(divide='raise'):
- x = np.array([0], dtype=np.complex)
- y = np.complex(-np.inf, 0)
+ x = np.array([0], dtype=complex)
+ y = complex(-np.inf, 0)
assert_raises(FloatingPointError, np.log, x)
with np.errstate(divide='ignore'):
assert_almost_equal(np.log(x), y)
@@ -172,13 +172,13 @@ class TestClog(object):
yl.append(y)
# clog(x + i inf returns +inf + i pi /2, for finite x.
- x = np.array([complex(1, np.inf)], dtype=np.complex)
- y = np.complex(np.inf, 0.5 * np.pi)
+ x = np.array([complex(1, np.inf)], dtype=complex)
+ y = complex(np.inf, 0.5 * np.pi)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
- x = np.array([complex(-1, np.inf)], dtype=np.complex)
+ x = np.array([complex(-1, np.inf)], dtype=complex)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
@@ -186,8 +186,8 @@ class TestClog(object):
# clog(x + iNaN) returns NaN + iNaN and optionally raises the
# 'invalid' floating- point exception, for finite x.
with np.errstate(invalid='raise'):
- x = np.array([complex(1., np.nan)], dtype=np.complex)
- y = np.complex(np.nan, np.nan)
+ x = np.array([complex(1., np.nan)], dtype=complex)
+ y = complex(np.nan, np.nan)
#assert_raises(FloatingPointError, np.log, x)
with np.errstate(invalid='ignore'):
assert_almost_equal(np.log(x), y)
@@ -196,7 +196,7 @@ class TestClog(object):
yl.append(y)
with np.errstate(invalid='raise'):
- x = np.array([np.inf + 1j * np.nan], dtype=np.complex)
+ x = np.array([np.inf + 1j * np.nan], dtype=complex)
#assert_raises(FloatingPointError, np.log, x)
with np.errstate(invalid='ignore'):
assert_almost_equal(np.log(x), y)
@@ -205,70 +205,70 @@ class TestClog(object):
yl.append(y)
# clog(- inf + iy) returns +inf + ipi , for finite positive-signed y.
- x = np.array([-np.inf + 1j], dtype=np.complex)
- y = np.complex(np.inf, np.pi)
+ x = np.array([-np.inf + 1j], dtype=complex)
+ y = complex(np.inf, np.pi)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(+ inf + iy) returns +inf + i0, for finite positive-signed y.
- x = np.array([np.inf + 1j], dtype=np.complex)
- y = np.complex(np.inf, 0)
+ x = np.array([np.inf + 1j], dtype=complex)
+ y = complex(np.inf, 0)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(- inf + i inf) returns +inf + i3pi /4.
- x = np.array([complex(-np.inf, np.inf)], dtype=np.complex)
- y = np.complex(np.inf, 0.75 * np.pi)
+ x = np.array([complex(-np.inf, np.inf)], dtype=complex)
+ y = complex(np.inf, 0.75 * np.pi)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(+ inf + i inf) returns +inf + ipi /4.
- x = np.array([complex(np.inf, np.inf)], dtype=np.complex)
- y = np.complex(np.inf, 0.25 * np.pi)
+ x = np.array([complex(np.inf, np.inf)], dtype=complex)
+ y = complex(np.inf, 0.25 * np.pi)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(+/- inf + iNaN) returns +inf + iNaN.
- x = np.array([complex(np.inf, np.nan)], dtype=np.complex)
- y = np.complex(np.inf, np.nan)
+ x = np.array([complex(np.inf, np.nan)], dtype=complex)
+ y = complex(np.inf, np.nan)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
- x = np.array([complex(-np.inf, np.nan)], dtype=np.complex)
+ x = np.array([complex(-np.inf, np.nan)], dtype=complex)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(NaN + iy) returns NaN + iNaN and optionally raises the
# 'invalid' floating-point exception, for finite y.
- x = np.array([complex(np.nan, 1)], dtype=np.complex)
- y = np.complex(np.nan, np.nan)
+ x = np.array([complex(np.nan, 1)], dtype=complex)
+ y = complex(np.nan, np.nan)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(NaN + i inf) returns +inf + iNaN.
- x = np.array([complex(np.nan, np.inf)], dtype=np.complex)
- y = np.complex(np.inf, np.nan)
+ x = np.array([complex(np.nan, np.inf)], dtype=complex)
+ y = complex(np.inf, np.nan)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(NaN + iNaN) returns NaN + iNaN.
- x = np.array([complex(np.nan, np.nan)], dtype=np.complex)
- y = np.complex(np.nan, np.nan)
+ x = np.array([complex(np.nan, np.nan)], dtype=complex)
+ y = complex(np.nan, np.nan)
assert_almost_equal(np.log(x), y)
xl.append(x)
yl.append(y)
# clog(conj(z)) = conj(clog(z)).
- xa = np.array(xl, dtype=np.complex)
- ya = np.array(yl, dtype=np.complex)
+ xa = np.array(xl, dtype=complex)
+ ya = np.array(yl, dtype=complex)
with np.errstate(divide='ignore'):
for i in range(len(xa)):
assert_almost_equal(np.log(xa[i].conj()), ya[i].conj())
@@ -286,7 +286,7 @@ class TestCsqrt(object):
yield check_complex_value, np.sqrt, -1, 0, 0, 1
def test_simple_conjugate(self):
- ref = np.conj(np.sqrt(np.complex(1, 1)))
+ ref = np.conj(np.sqrt(complex(1, 1)))
def f(z):
return np.sqrt(np.conj(z))
@@ -330,7 +330,7 @@ class TestCsqrt(object):
# csqrt(-inf + nani) is nan +- infi (both +i infi are valid)
def _check_ninf_nan(dummy):
msgform = "csqrt(-inf, nan) is (%f, %f), expected (nan, +-inf)"
- z = np.sqrt(np.array(np.complex(-np.inf, np.nan)))
+ z = np.sqrt(np.array(complex(-np.inf, np.nan)))
#Fixme: ugly workaround for isinf bug.
with np.errstate(invalid='ignore'):
if not (np.isnan(z.real) and np.isinf(z.imag)):
@@ -406,16 +406,16 @@ class TestCabs(object):
def test_fabs(self):
# Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs)
- x = np.array([1+0j], dtype=np.complex)
+ x = np.array([1+0j], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
- x = np.array([complex(1, np.NZERO)], dtype=np.complex)
+ x = np.array([complex(1, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
- x = np.array([complex(np.inf, np.NZERO)], dtype=np.complex)
+ x = np.array([complex(np.inf, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
- x = np.array([complex(np.nan, np.NZERO)], dtype=np.complex)
+ x = np.array([complex(np.nan, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
def test_cabs_inf_nan(self):
@@ -445,9 +445,9 @@ class TestCabs(object):
return np.abs(np.conj(a))
def g(a, b):
- return np.abs(np.complex(a, b))
+ return np.abs(complex(a, b))
- xa = np.array(x, dtype=np.complex)
+ xa = np.array(x, dtype=complex)
for i in range(len(xa)):
ref = g(x[i], y[i])
yield check_real_value, f, x[i], y[i], ref
@@ -527,7 +527,7 @@ def check_real_value(f, x1, y1, x, exact=True):
def check_complex_value(f, x1, y1, x2, y2, exact=True):
z1 = np.array([complex(x1, y1)])
- z2 = np.complex(x2, y2)
+ z2 = complex(x2, y2)
with np.errstate(invalid='ignore'):
if exact:
assert_equal(f(z1), z2)