diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-08-05 12:09:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-05 12:09:23 -0500 |
commit | bfe43b26969231cfe8196868280c07f0c0aa8f50 (patch) | |
tree | 88ad7478e033ce5980a365a479e22b78ba1cecaa /numpy/lib/tests | |
parent | 5ab02b15de72fa00d785f49c62466fe048264cc4 (diff) | |
parent | 2b781f8967488dc007f8f0a1e6a7f49208788d12 (diff) | |
download | numpy-bfe43b26969231cfe8196868280c07f0c0aa8f50.tar.gz |
Merge pull request #9517 from charris/rebase-9508
MAINT/DOC: Use builtin when np.{x} is builtins.{x}.
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 8 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 40 | ||||
-rw-r--r-- | numpy/lib/tests/test_regression.py | 18 | ||||
-rw-r--r-- | numpy/lib/tests/test_type_check.py | 4 |
5 files changed, 36 insertions, 36 deletions
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index a7ee9cbff..03192896c 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -257,7 +257,7 @@ class TestMiscFunctions(object): def test_has_nested_dtype(self): "Test has_nested_dtype" - ndtype = np.dtype(np.float) + ndtype = np.dtype(float) assert_equal(has_nested_fields(ndtype), False) ndtype = np.dtype([('A', '|S3'), ('B', float)]) assert_equal(has_nested_fields(ndtype), False) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 4ecb02821..ad840f8ef 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2663,28 +2663,28 @@ class TestInterp(object): incres = interp(incpts, xp, yp) decres = interp(decpts, xp, yp) - inctgt = np.array([1, 1, 1, 1], dtype=np.float) + inctgt = np.array([1, 1, 1, 1], dtype=float) dectgt = inctgt[::-1] assert_equal(incres, inctgt) assert_equal(decres, dectgt) incres = interp(incpts, xp, yp, left=0) decres = interp(decpts, xp, yp, left=0) - inctgt = np.array([0, 1, 1, 1], dtype=np.float) + inctgt = np.array([0, 1, 1, 1], dtype=float) dectgt = inctgt[::-1] assert_equal(incres, inctgt) assert_equal(decres, dectgt) incres = interp(incpts, xp, yp, right=2) decres = interp(decpts, xp, yp, right=2) - inctgt = np.array([1, 1, 1, 2], dtype=np.float) + inctgt = np.array([1, 1, 1, 2], dtype=float) dectgt = inctgt[::-1] assert_equal(incres, inctgt) assert_equal(decres, dectgt) incres = interp(incpts, xp, yp, left=0, right=2) decres = interp(decpts, xp, yp, left=0, right=2) - inctgt = np.array([0, 1, 1, 2], dtype=np.float) + inctgt = np.array([0, 1, 1, 2], dtype=float) dectgt = inctgt[::-1] assert_equal(incres, inctgt) assert_equal(decres, dectgt) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 4bc2a1b1b..f2fd37230 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -373,7 +373,7 @@ class TestSaveTxt(object): # Test the functionality of the header and footer keyword argument. c = BytesIO() - a = np.array([(1, 2), (3, 4)], dtype=np.int) + a = np.array([(1, 2), (3, 4)], dtype=int) test_header_footer = 'Test header / footer' # Test the header keyword argument np.savetxt(c, a, fmt='%1d', header=test_header_footer) @@ -485,7 +485,7 @@ class TestLoadTxt(object): c.write('1 2\n3 4') c.seek(0) - x = np.loadtxt(c, dtype=np.int) + x = np.loadtxt(c, dtype=int) a = np.array([[1, 2], [3, 4]], int) assert_array_equal(x, a) @@ -721,7 +721,7 @@ class TestLoadTxt(object): # Test using an explicit dtype with an object data = """ 1; 2001-01-01 2; 2002-01-31 """ - ndtype = [('idx', int), ('code', np.object)] + ndtype = [('idx', int), ('code', object)] func = lambda s: strptime(s.strip(), "%Y-%m-%d") converters = {1: func} test = np.loadtxt(TextIO(data), delimiter=";", dtype=ndtype, @@ -751,11 +751,11 @@ class TestLoadTxt(object): # IEEE doubles and floats only, otherwise the float32 # conversion may fail. tgt = np.logspace(-10, 10, 5).astype(np.float32) - tgt = np.hstack((tgt, -tgt)).astype(np.float) + tgt = np.hstack((tgt, -tgt)).astype(float) inp = '\n'.join(map(float.hex, tgt)) c = TextIO() c.write(inp) - for dt in [np.float, np.float32]: + for dt in [float, np.float32]: c.seek(0) res = np.loadtxt(c, dtype=dt) assert_equal(res, tgt, err_msg="%s" % dt) @@ -765,7 +765,7 @@ class TestLoadTxt(object): c = TextIO() c.write("%s %s" % tgt) c.seek(0) - res = np.loadtxt(c, dtype=np.complex) + res = np.loadtxt(c, dtype=complex) assert_equal(res, tgt) def test_universal_newline(self): @@ -1190,7 +1190,7 @@ M 33 21.99 # Test using an explicit dtype with an object data = """ 1; 2001-01-01 2; 2002-01-31 """ - ndtype = [('idx', int), ('code', np.object)] + ndtype = [('idx', int), ('code', object)] func = lambda s: strptime(s.strip(), "%Y-%m-%d") converters = {1: func} test = np.genfromtxt(TextIO(data), delimiter=";", dtype=ndtype, @@ -1200,7 +1200,7 @@ M 33 21.99 dtype=ndtype) assert_equal(test, control) - ndtype = [('nest', [('idx', int), ('code', np.object)])] + ndtype = [('nest', [('idx', int), ('code', object)])] try: test = np.genfromtxt(TextIO(data), delimiter=";", dtype=ndtype, converters=converters) @@ -1337,7 +1337,7 @@ M 33 21.99 test = np.mafromtxt(data, dtype=None, **kwargs) control = ma.array([(0, 1), (2, -1)], mask=[(False, False), (False, True)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_equal(test, control) assert_equal(test.mask, control.mask) # @@ -1345,7 +1345,7 @@ M 33 21.99 test = np.mafromtxt(data, **kwargs) control = ma.array([(0, 1), (2, -1)], mask=[(False, False), (False, True)], - dtype=[('A', np.float), ('B', np.float)]) + dtype=[('A', float), ('B', float)]) assert_equal(test, control) assert_equal(test.mask, control.mask) @@ -1414,7 +1414,7 @@ M 33 21.99 missing_values='-999.0', names=True,) control = ma.array([(0, 1.5), (2, -1.)], mask=[(False, False), (False, True)], - dtype=[('A', np.int), ('B', np.float)]) + dtype=[('A', int), ('B', float)]) assert_equal(test, control) assert_equal(test.mask, control.mask) @@ -1682,7 +1682,7 @@ M 33 21.99 kwargs = dict(delimiter=",", missing_values="N/A", names=True) test = np.recfromtxt(data, **kwargs) control = np.array([(0, 1), (2, 3)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control) # @@ -1690,7 +1690,7 @@ M 33 21.99 test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs) control = ma.array([(0, 1), (2, -1)], mask=[(False, False), (False, True)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_equal(test, control) assert_equal(test.mask, control.mask) assert_equal(test.A, [0, 2]) @@ -1701,7 +1701,7 @@ M 33 21.99 kwargs = dict(missing_values="N/A", names=True, case_sensitive=True) test = np.recfromcsv(data, dtype=None, **kwargs) control = np.array([(0, 1), (2, 3)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control) # @@ -1709,7 +1709,7 @@ M 33 21.99 test = np.recfromcsv(data, dtype=None, usemask=True, **kwargs) control = ma.array([(0, 1), (2, -1)], mask=[(False, False), (False, True)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_equal(test, control) assert_equal(test.mask, control.mask) assert_equal(test.A, [0, 2]) @@ -1717,12 +1717,12 @@ M 33 21.99 data = TextIO('A,B\n0,1\n2,3') test = np.recfromcsv(data, missing_values='N/A',) control = np.array([(0, 1), (2, 3)], - dtype=[('a', np.int), ('b', np.int)]) + dtype=[('a', int), ('b', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control) # data = TextIO('A,B\n0,1\n2,3') - dtype = [('a', np.int), ('b', np.float)] + dtype = [('a', int), ('b', float)] test = np.recfromcsv(data, missing_values='N/A', dtype=dtype) control = np.array([(0, 1), (2, 3)], dtype=dtype) @@ -1827,7 +1827,7 @@ M 33 21.99 assert_equal(test.dtype.names, ['f0', 'f1', 'f2']) - assert_(test.dtype['f0'] == np.float) + assert_(test.dtype['f0'] == float) assert_(test.dtype['f1'] == np.int64) assert_(test.dtype['f2'] == np.integer) @@ -1919,7 +1919,7 @@ class TestPathUsage(object): kwargs = dict(delimiter=",", missing_values="N/A", names=True) test = np.recfromtxt(path, **kwargs) control = np.array([(0, 1), (2, 3)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control) @@ -1933,7 +1933,7 @@ class TestPathUsage(object): kwargs = dict(missing_values="N/A", names=True, case_sensitive=True) test = np.recfromcsv(path, dtype=None, **kwargs) control = np.array([(0, 1), (2, 3)], - dtype=[('A', np.int), ('B', np.int)]) + dtype=[('A', int), ('B', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control) diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index 1567219d6..74c47df7c 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -108,13 +108,13 @@ class TestRegression(object): def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" - x = np.ones(3, dtype=np.complex) + x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) - assert_(q.dtype == np.complex, msg) + assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" - x = np.ones(3, dtype=np.int) + x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) - assert_(q.dtype == np.float, msg) + assert_(q.dtype == float, msg) def test_histogramdd_too_many_bins(self): # Ticket 928. @@ -123,11 +123,11 @@ class TestRegression(object): def test_polyint_type(self): # Ticket #944 msg = "Wrong type, should be complex" - x = np.ones(3, dtype=np.complex) - assert_(np.polyint(x).dtype == np.complex, msg) + x = np.ones(3, dtype=complex) + assert_(np.polyint(x).dtype == complex, msg) msg = "Wrong type, should be float" - x = np.ones(3, dtype=np.int) - assert_(np.polyint(x).dtype == np.float, msg) + x = np.ones(3, dtype=int) + assert_(np.polyint(x).dtype == float, msg) def test_ndenumerate_crash(self): # Ticket 1140 @@ -234,7 +234,7 @@ class TestRegression(object): def test_nansum_with_boolean(self): # gh-2978 - a = np.zeros(2, dtype=np.bool) + a = np.zeros(2, dtype=bool) try: np.nansum(a) except Exception: diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index 259fcd4e5..d863e5924 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -374,7 +374,7 @@ class TestNanToNum(object): vals = nan_to_num(1) assert_all(vals == 1) vals = nan_to_num([1]) - assert_array_equal(vals, np.array([1], np.int)) + assert_array_equal(vals, np.array([1], int)) def test_complex_good(self): vals = nan_to_num(1+1j) @@ -420,7 +420,7 @@ class TestArrayConversion(object): def test_asfarray(self): a = asfarray(np.array([1, 2, 3])) assert_equal(a.__class__, np.ndarray) - assert_(np.issubdtype(a.dtype, np.float)) + assert_(np.issubdtype(a.dtype, float)) if __name__ == "__main__": run_module_suite() |