summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorAllan Haldane <allan.haldane@gmail.com>2017-10-29 15:40:40 -0400
committerAllan Haldane <allan.haldane@gmail.com>2017-11-04 15:12:53 -0400
commit39551ef50f491467c33bfde573f46cf03ac1ba75 (patch)
treeae10e5dfddbf3249a2db1e1178ec95b4f3282ff8 /numpy/core
parent0cf5cc025211214af2056ed6dc26c3d4c507bc8f (diff)
downloadnumpy-39551ef50f491467c33bfde573f46cf03ac1ba75.tar.gz
TST: update tests to account for dragon4 fixes
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/test_arrayprint.py81
-rw-r--r--numpy/core/tests/test_getlimits.py2
-rw-r--r--numpy/core/tests/test_print.py50
-rw-r--r--numpy/core/tests/test_scalarprint.py23
4 files changed, 79 insertions, 77 deletions
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 26faabfb8..42fbc68cb 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -72,42 +72,42 @@ class TestComplexArray(object):
dtypes = [np.complex64, np.cdouble, np.clongdouble]
actual = [str(np.array([c], dt)) for c in cvals for dt in dtypes]
wanted = [
- '[0.+0.j]', '[0.+0.j]', '[ 0.0+0.0j]',
- '[0.+1.j]', '[0.+1.j]', '[ 0.0+1.0j]',
- '[0.-1.j]', '[0.-1.j]', '[ 0.0-1.0j]',
- '[0.+infj]', '[0.+infj]', '[ 0.0+infj]',
- '[0.-infj]', '[0.-infj]', '[ 0.0-infj]',
- '[0.+nanj]', '[0.+nanj]', '[ 0.0+nanj]',
- '[1.+0.j]', '[1.+0.j]', '[ 1.0+0.0j]',
- '[1.+1.j]', '[1.+1.j]', '[ 1.0+1.0j]',
- '[1.-1.j]', '[1.-1.j]', '[ 1.0-1.0j]',
- '[1.+infj]', '[1.+infj]', '[ 1.0+infj]',
- '[1.-infj]', '[1.-infj]', '[ 1.0-infj]',
- '[1.+nanj]', '[1.+nanj]', '[ 1.0+nanj]',
- '[-1.+0.j]', '[-1.+0.j]', '[-1.0+0.0j]',
- '[-1.+1.j]', '[-1.+1.j]', '[-1.0+1.0j]',
- '[-1.-1.j]', '[-1.-1.j]', '[-1.0-1.0j]',
- '[-1.+infj]', '[-1.+infj]', '[-1.0+infj]',
- '[-1.-infj]', '[-1.-infj]', '[-1.0-infj]',
- '[-1.+nanj]', '[-1.+nanj]', '[-1.0+nanj]',
- '[inf+0.j]', '[inf+0.j]', '[ inf+0.0j]',
- '[inf+1.j]', '[inf+1.j]', '[ inf+1.0j]',
- '[inf-1.j]', '[inf-1.j]', '[ inf-1.0j]',
- '[inf+infj]', '[inf+infj]', '[ inf+infj]',
- '[inf-infj]', '[inf-infj]', '[ inf-infj]',
- '[inf+nanj]', '[inf+nanj]', '[ inf+nanj]',
- '[-inf+0.j]', '[-inf+0.j]', '[-inf+0.0j]',
- '[-inf+1.j]', '[-inf+1.j]', '[-inf+1.0j]',
- '[-inf-1.j]', '[-inf-1.j]', '[-inf-1.0j]',
- '[-inf+infj]', '[-inf+infj]', '[-inf+infj]',
- '[-inf-infj]', '[-inf-infj]', '[-inf-infj]',
- '[-inf+nanj]', '[-inf+nanj]', '[-inf+nanj]',
- '[nan+0.j]', '[nan+0.j]', '[ nan+0.0j]',
- '[nan+1.j]', '[nan+1.j]', '[ nan+1.0j]',
- '[nan-1.j]', '[nan-1.j]', '[ nan-1.0j]',
- '[nan+infj]', '[nan+infj]', '[ nan+infj]',
- '[nan-infj]', '[nan-infj]', '[ nan-infj]',
- '[nan+nanj]', '[nan+nanj]', '[ nan+nanj]']
+ '[0.+0.j]', '[0.+0.j]', '[0.+0.j]',
+ '[0.+1.j]', '[0.+1.j]', '[0.+1.j]',
+ '[0.-1.j]', '[0.-1.j]', '[0.-1.j]',
+ '[0.+infj]', '[0.+infj]', '[0.+infj]',
+ '[0.-infj]', '[0.-infj]', '[0.-infj]',
+ '[0.+nanj]', '[0.+nanj]', '[0.+nanj]',
+ '[1.+0.j]', '[1.+0.j]', '[1.+0.j]',
+ '[1.+1.j]', '[1.+1.j]', '[1.+1.j]',
+ '[1.-1.j]', '[1.-1.j]', '[1.-1.j]',
+ '[1.+infj]', '[1.+infj]', '[1.+infj]',
+ '[1.-infj]', '[1.-infj]', '[1.-infj]',
+ '[1.+nanj]', '[1.+nanj]', '[1.+nanj]',
+ '[-1.+0.j]', '[-1.+0.j]', '[-1.+0.j]',
+ '[-1.+1.j]', '[-1.+1.j]', '[-1.+1.j]',
+ '[-1.-1.j]', '[-1.-1.j]', '[-1.-1.j]',
+ '[-1.+infj]', '[-1.+infj]', '[-1.+infj]',
+ '[-1.-infj]', '[-1.-infj]', '[-1.-infj]',
+ '[-1.+nanj]', '[-1.+nanj]', '[-1.+nanj]',
+ '[inf+0.j]', '[inf+0.j]', '[inf+0.j]',
+ '[inf+1.j]', '[inf+1.j]', '[inf+1.j]',
+ '[inf-1.j]', '[inf-1.j]', '[inf-1.j]',
+ '[inf+infj]', '[inf+infj]', '[inf+infj]',
+ '[inf-infj]', '[inf-infj]', '[inf-infj]',
+ '[inf+nanj]', '[inf+nanj]', '[inf+nanj]',
+ '[-inf+0.j]', '[-inf+0.j]', '[-inf+0.j]',
+ '[-inf+1.j]', '[-inf+1.j]', '[-inf+1.j]',
+ '[-inf-1.j]', '[-inf-1.j]', '[-inf-1.j]',
+ '[-inf+infj]', '[-inf+infj]', '[-inf+infj]',
+ '[-inf-infj]', '[-inf-infj]', '[-inf-infj]',
+ '[-inf+nanj]', '[-inf+nanj]', '[-inf+nanj]',
+ '[nan+0.j]', '[nan+0.j]', '[nan+0.j]',
+ '[nan+1.j]', '[nan+1.j]', '[nan+1.j]',
+ '[nan-1.j]', '[nan-1.j]', '[nan-1.j]',
+ '[nan+infj]', '[nan+infj]', '[nan+infj]',
+ '[nan-infj]', '[nan-infj]', '[nan-infj]',
+ '[nan+nanj]', '[nan+nanj]', '[nan+nanj]']
for res, val in zip(actual, wanted):
assert_equal(res, val)
@@ -290,22 +290,23 @@ class TestPrintOptions(object):
assert_equal(repr(a), 'array([0., 1., 2., 3.])')
assert_equal(repr(np.array(1.)), 'array(1.)')
- assert_equal(repr(b), 'array([1.23400000e+09])')
+ assert_equal(repr(b), 'array([1.234e+09])')
np.set_printoptions(sign=' ')
assert_equal(repr(a), 'array([ 0., 1., 2., 3.])')
assert_equal(repr(np.array(1.)), 'array( 1.)')
- assert_equal(repr(b), 'array([ 1.23400000e+09])')
+ assert_equal(repr(b), 'array([ 1.234e+09])')
np.set_printoptions(sign='+')
assert_equal(repr(a), 'array([+0., +1., +2., +3.])')
assert_equal(repr(np.array(1.)), 'array(+1.)')
- assert_equal(repr(b), 'array([+1.23400000e+09])')
+ assert_equal(repr(b), 'array([+1.234e+09])')
np.set_printoptions(sign='legacy')
assert_equal(repr(a), 'array([ 0., 1., 2., 3.])')
assert_equal(repr(np.array(1.)), 'array(1.)')
- assert_equal(repr(b), 'array([ 1.23400000e+09])')
+ assert_equal(repr(b), 'array([ 1.23400000e+09])')
+ assert_equal(repr(-b), 'array([ -1.23400000e+09])')
def test_sign_spacing_structured(self):
a = np.ones(2, dtype='f,f')
diff --git a/numpy/core/tests/test_getlimits.py b/numpy/core/tests/test_getlimits.py
index 455f5257c..361246c7f 100644
--- a/numpy/core/tests/test_getlimits.py
+++ b/numpy/core/tests/test_getlimits.py
@@ -80,7 +80,7 @@ class TestRepr(object):
assert_equal(repr(np.iinfo(np.int16)), expected)
def test_finfo_repr(self):
- expected = "finfo(resolution=1e-06, min=-3.4028235e+38," + \
+ expected = "finfo(resolution=0.000001, min=-3.4028235e+38," + \
" max=3.4028235e+38, dtype=float32)"
assert_equal(repr(np.finfo(np.float32)), expected)
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py
index 305258d6f..4b5c5f81f 100644
--- a/numpy/core/tests/test_print.py
+++ b/numpy/core/tests/test_print.py
@@ -23,12 +23,12 @@ def check_float_type(tp):
assert_equal(str(tp(x)), str(float(x)),
err_msg='Failed str formatting for type %s' % tp)
- if tp(1e10).itemsize > 4:
- assert_equal(str(tp(1e10)), str(float('1e10')),
+ if tp(1e16).itemsize > 4:
+ assert_equal(str(tp(1e16)), str(float('1e16')),
err_msg='Failed str formatting for type %s' % tp)
else:
- ref = '1e+10'
- assert_equal(str(tp(1e10)), ref,
+ ref = '1e+16'
+ assert_equal(str(tp(1e16)), ref,
err_msg='Failed str formatting for type %s' % tp)
def test_float_types():
@@ -67,12 +67,12 @@ def check_complex_type(tp):
assert_equal(str(tp(x + x*1j)), str(complex(x + x*1j)),
err_msg='Failed str formatting for type %s' % tp)
- if tp(1e10).itemsize > 8:
- assert_equal(str(tp(1e10)), str(complex(1e10)),
+ if tp(1e16).itemsize > 8:
+ assert_equal(str(tp(1e16)), str(complex(1e16)),
err_msg='Failed str formatting for type %s' % tp)
else:
- ref = '(1e+10+0j)'
- assert_equal(str(tp(1e10)), ref,
+ ref = '(1e+16+0j)'
+ assert_equal(str(tp(1e16)), ref,
err_msg='Failed str formatting for type %s' % tp)
def test_complex_types():
@@ -90,21 +90,21 @@ def test_complex_inf_nan():
"""Check inf/nan formatting of complex types."""
TESTS = {
complex(np.inf, 0): "(inf+0j)",
- complex(0, np.inf): "inf*j",
+ complex(0, np.inf): "infj",
complex(-np.inf, 0): "(-inf+0j)",
- complex(0, -np.inf): "-inf*j",
+ complex(0, -np.inf): "-infj",
complex(np.inf, 1): "(inf+1j)",
- complex(1, np.inf): "(1+inf*j)",
+ complex(1, np.inf): "(1+infj)",
complex(-np.inf, 1): "(-inf+1j)",
- complex(1, -np.inf): "(1-inf*j)",
+ complex(1, -np.inf): "(1-infj)",
complex(np.nan, 0): "(nan+0j)",
- complex(0, np.nan): "nan*j",
+ complex(0, np.nan): "nanj",
complex(-np.nan, 0): "(nan+0j)",
- complex(0, -np.nan): "nan*j",
+ complex(0, -np.nan): "nanj",
complex(np.nan, 1): "(nan+1j)",
- complex(1, np.nan): "(1+nan*j)",
+ complex(1, np.nan): "(1+nanj)",
complex(-np.nan, 1): "(nan+1j)",
- complex(1, -np.nan): "(1+nan*j)",
+ complex(1, -np.nan): "(1+nanj)",
}
for tp in [np.complex64, np.cdouble, np.clongdouble]:
for c, s in TESTS.items():
@@ -139,11 +139,11 @@ def check_float_type_print(tp):
for x in [np.inf, -np.inf, np.nan]:
_test_redirected_print(float(x), tp, _REF[x])
- if tp(1e10).itemsize > 4:
- _test_redirected_print(float(1e10), tp)
+ if tp(1e16).itemsize > 4:
+ _test_redirected_print(float(1e16), tp)
else:
- ref = '1e+10'
- _test_redirected_print(float(1e10), tp, ref)
+ ref = '1e+16'
+ _test_redirected_print(float(1e16), tp, ref)
def check_complex_type_print(tp):
# We do not create complex with inf/nan directly because the feature is
@@ -151,11 +151,11 @@ def check_complex_type_print(tp):
for x in [0, 1, -1, 1e20]:
_test_redirected_print(complex(x), tp)
- if tp(1e10).itemsize > 8:
- _test_redirected_print(complex(1e10), tp)
+ if tp(1e16).itemsize > 8:
+ _test_redirected_print(complex(1e16), tp)
else:
- ref = '(1e+10+0j)'
- _test_redirected_print(complex(1e10), tp, ref)
+ ref = '(1e+16+0j)'
+ _test_redirected_print(complex(1e16), tp, ref)
_test_redirected_print(complex(np.inf, 1), tp, '(inf+1j)')
_test_redirected_print(complex(-np.inf, 1), tp, '(-inf+1j)')
@@ -240,7 +240,7 @@ def test_locale_double():
@in_foreign_locale
def test_locale_longdouble():
- assert_equal(str(np.longdouble(1.2)), str(float(1.2)))
+ assert_equal(str(np.longdouble('1.2')), str(float(1.2)))
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py
index 7e17e0425..5e804bd2d 100644
--- a/numpy/core/tests/test_scalarprint.py
+++ b/numpy/core/tests/test_scalarprint.py
@@ -5,25 +5,26 @@
from __future__ import division, absolute_import, print_function
import numpy as np
-from numpy.testing import assert_, run_module_suite
+from numpy.testing import assert_equal, run_module_suite
class TestRealScalars(object):
def test_str(self):
svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan]
styps = [np.float16, np.float32, np.float64, np.longdouble]
- actual = [str(f(c)) for c in svals for f in styps]
wanted = [
- '0.0', '0.0', '0.0', '0.0',
- '-0.0', '-0.0', '-0.0', '-0.0',
- '1.0', '1.0', '1.0', '1.0',
- '-1.0', '-1.0', '-1.0', '-1.0',
- 'inf', 'inf', 'inf', 'inf',
- '-inf', '-inf', '-inf', '-inf',
- 'nan', 'nan', 'nan', 'nan']
+ ['0.0', '0.0', '0.0', '0.0' ],
+ ['-0.0', '-0.0', '-0.0', '-0.0'],
+ ['1.0', '1.0', '1.0', '1.0' ],
+ ['-1.0', '-1.0', '-1.0', '-1.0'],
+ ['inf', 'inf', 'inf', 'inf' ],
+ ['-inf', '-inf', '-inf', '-inf'],
+ ['nan', 'nan', 'nan', 'nan']]
- for res, val in zip(actual, wanted):
- assert_(res == val)
+ for wants, val in zip(wanted, svals):
+ for want, styp in zip(wants, styps):
+ msg = 'for str({}({}))'.format(np.dtype(styp).name, repr(val))
+ assert_equal(str(styp(val)), want, err_msg=msg)
if __name__ == "__main__":