Skip to content

Instantly share code, notes, and snippets.

@marxin
Created May 12, 2020 09:21
Show Gist options
  • Save marxin/83f18c2cd9792c6b9cfcc7964b2e56d3 to your computer and use it in GitHub Desktop.
Save marxin/83f18c2cd9792c6b9cfcc7964b2e56d3 to your computer and use it in GitHub Desktop.
[ 213s] =================================== FAILURES ===================================
[ 213s] _______________________________ test_array_array _______________________________
[ 213s] [gw9] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] def test_array_array():
[ 213s] tobj = type(object)
[ 213s] ones11 = np.ones((1, 1), np.float64)
[ 213s] tndarray = type(ones11)
[ 213s] # Test is_ndarray
[ 213s] assert_equal(np.array(ones11, dtype=np.float64), ones11)
[ 213s] if HAS_REFCOUNT:
[ 213s] old_refcount = sys.getrefcount(tndarray)
[ 213s] np.array(ones11)
[ 213s] assert_equal(old_refcount, sys.getrefcount(tndarray))
[ 213s]
[ 213s] # test None
[ 213s] > assert_equal(np.array(None, dtype=np.float64),
[ 213s] np.array(np.nan, dtype=np.float64))
[ 213s]
[ 213s] old_refcount = 244
[ 213s] ones11 = array([[1.]])
[ 213s] tndarray = <class 'numpy.ndarray'>
[ 213s] tobj = <class 'type'>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_api.py:28:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________________________ TestClip.test_nan _______________________________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestClip object at 0xf22a9a60>
[ 213s]
[ 213s] def test_nan(self):
[ 213s] input_arr = np.array([-2., np.nan, 0.5, 3., 0.25, np.nan])
[ 213s] result = input_arr.clip(-1, 1)
[ 213s] expected = np.array([-1., np.nan, 0.5, 1., 0.25, np.nan])
[ 213s] > assert_array_equal(result, expected)
[ 213s]
[ 213s] expected = array([-1. , nan, 0.5 , 1. , 0.25, nan])
[ 213s] input_arr = array([-2. , nan, 0.5 , 3. , 0.25, nan])
[ 213s] result = array([-1. , nan, 0.5 , 1. , 0.25, nan])
[ 213s] self = <numpy.core.tests.test_multiarray.TestClip object at 0xf22a9a60>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4439:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([-1. , nan, 0.5 , 1. , 0.25, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([-1. , nan, 0.5 , 1. , 0.25, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________________ TestIO.test_roundtrip_binary_str _______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xefee9b98>
[ 213s]
[ 213s] def test_roundtrip_binary_str(self):
[ 213s] s = self.x.tobytes()
[ 213s] y = np.frombuffer(s, dtype=self.dtype)
[ 213s] > assert_array_equal(y, self.x.flat)
[ 213s]
[ 213s] s = b"\xd0i\xf26K\xb2\xdb?p\x0f\xc9C\xb6\xbb\xdd?\x00\x00\x00\x00\x00\x00\xf8\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x90\x8c\...2\xe0?@\x7f8\x00\xa5\x9b\xa9?`I\xddS.\x9c\xa3?\xf2B}\xd7\xad\x19\xd3?(i\xa9\xd6\x986\xe7?\xa8\xfb\xd9\xa3\xdb\xd1\xca?"
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xefee9b98>
[ 213s] y = array([0.43275719+0.46458203j, nan+0.j ,
[ 213s] 0.47976629+0.08079011j, 0.0980964 +0.68652323j,
[ 213s] ...561608j,
[ 213s] 0.93235678+0.59374057j, 0.50615298+0.0500156j ,
[ 213s] 0.03830094+0.29844233j, 0.72541468+0.20952936j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4708:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([0.43275719+0.46458203j, nan+0.j ,
[ 213s] 0.47976629+0.08079011j, 0.0980964 +0.68652323j,
[ 213s] ...561608j,
[ 213s] 0.93235678+0.59374057j, 0.50615298+0.0500156j ,
[ 213s] 0.03830094+0.29844233j, 0.72541468+0.20952936j])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([0.43275719+0.46458203j, nan+0.j ,
[ 213s] 0.47976629+0.08079011j, 0.0980964 +0.68652323j,
[ 213s] ...561608j,
[ 213s] 0.93235678+0.59374057j, 0.50615298+0.0500156j ,
[ 213s] 0.03830094+0.29844233j, 0.72541468+0.20952936j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] __________________________ TestIO.test_roundtrip_str ___________________________
[ 213s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2e66be0>
[ 213s]
[ 213s] def test_roundtrip_str(self):
[ 213s] x = self.x.real.ravel()
[ 213s] s = "@".join(map(str, x))
[ 213s] y = np.fromstring(s, sep="@")
[ 213s] # NB. str imbues less precision
[ 213s] nan_mask = ~np.isfinite(x)
[ 213s] > assert_array_equal(x[nan_mask], y[nan_mask])
[ 213s]
[ 213s] nan_mask = array([False, True, False, False, True, False, False, True, False,
[ 213s] False, True, False, False, False, False, False, False, False,
[ 213s] False, False, False, False, False, False])
[ 213s] s = '0.08575895977985137@nan@0.8501156927589057@0.3291839374740613@inf@0.9195815136971798@0.7443425469693298@-inf@0.482866...6@0.07062165204776316@0.3916077434370532@0.41073081022665114@0.9483833609288769@0.5060903413326439@0.05014610941876729'
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2e66be0>
[ 213s] x = array([0.08575896, nan, 0.85011569, 0.32918394, inf,
[ 213s] 0.91958151, 0.74434255, -inf, 0.482866... 0.55961741, 0.97351532, 0.44520595, 0.07062165, 0.39160774,
[ 213s] 0.41073081, 0.94838336, 0.50609034, 0.05014611])
[ 213s] y = array([0.08575896, nan, 0.85011569, 0.32918394, inf,
[ 213s] 0.91958151, 0.74434255, -inf, 0.482866... 0.55961741, 0.97351532, 0.44520595, 0.07062165, 0.39160774,
[ 213s] 0.41073081, 0.94838336, 0.50609034, 0.05014611])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4720:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([ nan, inf, -inf, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([ nan, inf, -inf, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________________ TestIsclose.test_ip_none_isclose _______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xefd4fb08>
[ 213s]
[ 213s] def test_ip_none_isclose(self):
[ 213s] self.setup()
[ 213s] for (x, y) in self.none_close_tests:
[ 213s] > self.tst_none_isclose(x, y)
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xefd4fb08>
[ 213s] x = [nan, 0]
[ 213s] y = [nan, -inf]
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2189:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2171: in tst_none_isclose
[ 213s] assert_(not np.any(np.isclose(x, y)), msg % (x, y))
[ 213s] <__array_function__ internals>:5: in isclose
[ 213s] ???
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] a = [nan, 0], b = [nan, -inf], rtol = 1e-05, atol = 1e-08, equal_nan = False
[ 213s]
[ 213s] @array_function_dispatch(_isclose_dispatcher)
[ 213s] def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
[ 213s] """
[ 213s] Returns a boolean array where two arrays are element-wise equal within a
[ 213s] tolerance.
[ 213s]
[ 213s] The tolerance values are positive, typically very small numbers. The
[ 213s] relative difference (`rtol` * abs(`b`)) and the absolute difference
[ 213s] `atol` are added together to compare against the absolute difference
[ 213s] between `a` and `b`.
[ 213s]
[ 213s] .. warning:: The default `atol` is not appropriate for comparing numbers
[ 213s] that are much smaller than one (see Notes).
[ 213s]
[ 213s] Parameters
[ 213s] ----------
[ 213s] a, b : array_like
[ 213s] Input arrays to compare.
[ 213s] rtol : float
[ 213s] The relative tolerance parameter (see Notes).
[ 213s] atol : float
[ 213s] The absolute tolerance parameter (see Notes).
[ 213s] equal_nan : bool
[ 213s] Whether to compare NaN's as equal. If True, NaN's in `a` will be
[ 213s] considered equal to NaN's in `b` in the output array.
[ 213s]
[ 213s] Returns
[ 213s] -------
[ 213s] y : array_like
[ 213s] Returns a boolean array of where `a` and `b` are equal within the
[ 213s] given tolerance. If both `a` and `b` are scalars, returns a single
[ 213s] boolean value.
[ 213s]
[ 213s] See Also
[ 213s] --------
[ 213s] allclose
[ 213s]
[ 213s] Notes
[ 213s] -----
[ 213s] .. versionadded:: 1.7.0
[ 213s]
[ 213s] For finite values, isclose uses the following equation to test whether
[ 213s] two floating point values are equivalent.
[ 213s]
[ 213s] absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
[ 213s]
[ 213s] Unlike the built-in `math.isclose`, the above equation is not symmetric
[ 213s] in `a` and `b` -- it assumes `b` is the reference value -- so that
[ 213s] `isclose(a, b)` might be different from `isclose(b, a)`. Furthermore,
[ 213s] the default value of atol is not zero, and is used to determine what
[ 213s] small values should be considered close to zero. The default value is
[ 213s] appropriate for expected values of order unity: if the expected values
[ 213s] are significantly smaller than one, it can result in false positives.
[ 213s] `atol` should be carefully selected for the use case at hand. A zero value
[ 213s] for `atol` will result in `False` if either `a` or `b` is zero.
[ 213s]
[ 213s] Examples
[ 213s] --------
[ 213s] >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
[ 213s] array([False, True])
[ 213s] >>> np.isclose([1.0, np.nan], [1.0, np.nan])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
[ 213s] array([False, False])
[ 213s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
[ 213s] array([False, True])
[ 213s] """
[ 213s] def within_tol(x, y, atol, rtol):
[ 213s] with errstate(invalid='ignore'):
[ 213s] return less_equal(abs(x-y), atol + rtol * abs(y))
[ 213s]
[ 213s] x = asanyarray(a)
[ 213s] y = asanyarray(b)
[ 213s]
[ 213s] # Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
[ 213s] # This will cause casting of x later. Also, make sure to allow subclasses
[ 213s] # (e.g., for numpy.ma).
[ 213s] dt = multiarray.result_type(y, 1.)
[ 213s] y = array(y, dtype=dt, copy=False, subok=True)
[ 213s]
[ 213s] xfin = isfinite(x)
[ 213s] yfin = isfinite(y)
[ 213s] if all(xfin) and all(yfin):
[ 213s] return within_tol(x, y, atol, rtol)
[ 213s] else:
[ 213s] finite = xfin & yfin
[ 213s] cond = zeros_like(finite, subok=True)
[ 213s] # Because we're using boolean indexing, x & y must be the same shape.
[ 213s] # Ideally, we'd just do x, y = broadcast_arrays(x, y). It's in
[ 213s] # lib.stride_tricks, though, so we can't import it here.
[ 213s] x = x * ones_like(cond)
[ 213s] y = y * ones_like(cond)
[ 213s] # Avoid subtraction with infinite/nan values...
[ 213s] cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
[ 213s] # Check for equality of infinite values...
[ 213s] > cond[~finite] = (x[~finite] == y[~finite])
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] a = [nan, 0]
[ 213s] atol = 1e-08
[ 213s] b = [nan, -inf]
[ 213s] cond = array([False, False])
[ 213s] dt = dtype('float64')
[ 213s] equal_nan = False
[ 213s] finite = array([False, False])
[ 213s] rtol = 1e-05
[ 213s] within_tol = <function isclose.<locals>.within_tol at 0xdae9c388>
[ 213s] x = array([nan, 0.])
[ 213s] xfin = array([False, True])
[ 213s] y = array([ nan, -inf])
[ 213s] yfin = array([False, False])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/numeric.py:2272: DeprecationWarning
[ 213s] _____________________________ test_npymath_complex _____________________________
[ 213s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] def test_npymath_complex():
[ 213s] # Smoketest npymath functions
[ 213s] from numpy.core._multiarray_tests import (
[ 213s] npy_cabs, npy_carg)
[ 213s]
[ 213s] funcs = {npy_cabs: np.absolute,
[ 213s] npy_carg: np.angle}
[ 213s] vals = (1, np.inf, -np.inf, np.nan)
[ 213s] types = (np.complex64, np.complex128, np.clongdouble)
[ 213s]
[ 213s] for fun, npfun in funcs.items():
[ 213s] for x, y in itertools.product(vals, vals):
[ 213s] for t in types:
[ 213s] z = t(complex(x, y))
[ 213s] got = fun(z)
[ 213s] expected = npfun(z)
[ 213s] > assert_allclose(got, expected)
[ 213s]
[ 213s] expected = nan
[ 213s] fun = <built-in function npy_cabs>
[ 213s] funcs = {<built-in function npy_cabs>: <ufunc 'absolute'>, <built-in function npy_carg>: <function angle at 0xddf47ec8>}
[ 213s] got = array(nan)
[ 213s] npfun = <ufunc 'absolute'>
[ 213s] npy_cabs = <built-in function npy_cabs>
[ 213s] npy_carg = <built-in function npy_carg>
[ 213s] t = <class 'numpy.complex64'>
[ 213s] types = (<class 'numpy.complex64'>, <class 'numpy.complex128'>, <class 'numpy.complex192'>)
[ 213s] vals = (1, inf, -inf, nan)
[ 213s] x = 1
[ 213s] y = nan
[ 213s] z = (1+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:8286:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________________ test_ufunc_noncontiguous[arccos] _______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] ufunc = <ufunc 'arccos'>
[ 213s]
[ 213s] @pytest.mark.parametrize('ufunc', [getattr(np, x) for x in dir(np)
[ 213s] if isinstance(getattr(np, x), np.ufunc)])
[ 213s] def test_ufunc_noncontiguous(ufunc):
[ 213s] '''
[ 213s] Check that contiguous and non-contiguous calls to ufuncs
[ 213s] have the same results for values in range(9)
[ 213s] '''
[ 213s] for typ in ufunc.types:
[ 213s] # types is a list of strings like ii->i
[ 213s] if any(set('O?mM') & set(typ)):
[ 213s] # bool, object, datetime are too irregular for this simple test
[ 213s] continue
[ 213s] inp, out = typ.split('->')
[ 213s] args_c = [np.empty(6, t) for t in inp]
[ 213s] args_n = [np.empty(18, t)[::3] for t in inp]
[ 213s] for a in args_c:
[ 213s] a.flat = range(1,7)
[ 213s] for a in args_n:
[ 213s] a.flat = range(1,7)
[ 213s] with warnings.catch_warnings(record=True):
[ 213s] warnings.filterwarnings("always")
[ 213s] res_c = ufunc(*args_c)
[ 213s] res_n = ufunc(*args_n)
[ 213s] if len(out) == 1:
[ 213s] res_c = (res_c,)
[ 213s] res_n = (res_n,)
[ 213s] for c_ar, n_ar in zip(res_c, res_n):
[ 213s] dt = c_ar.dtype
[ 213s] if np.issubdtype(dt, np.floating):
[ 213s] # for floating point results allow a small fuss in comparisons
[ 213s] # since different algorithms (libm vs. intrinsics) can be used
[ 213s] # for different input strides
[ 213s] res_eps = np.finfo(dt).eps
[ 213s] tol = 2*res_eps
[ 213s] > assert_allclose(res_c, res_n, atol=tol, rtol=tol)
[ 213s]
[ 213s] a = array([1., 2., 3., 4., 5., 6.], dtype=float32)
[ 213s] args_c = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] args_n = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] c_ar = array([ 0., nan, nan, nan, nan, nan], dtype=float32)
[ 213s] dt = dtype('float32')
[ 213s] inp = 'f'
[ 213s] n_ar = array([ 0., nan, nan, nan, nan, nan], dtype=float32)
[ 213s] out = 'f'
[ 213s] res_c = (array([ 0., nan, nan, nan, nan, nan], dtype=float32),)
[ 213s] res_eps = 1.1920929e-07
[ 213s] res_n = (array([ 0., nan, nan, nan, nan, nan], dtype=float32),)
[ 213s] tol = 2.384185791015625e-07
[ 213s] typ = 'f->f'
[ 213s] ufunc = <ufunc 'arccos'>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_ufunc.py:1946:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[ 0., nan, nan, nan, nan, nan]], dtype=float32)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[ 0., nan, nan, nan, nan, nan]], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________________ test_ufunc_noncontiguous[arcsin] _______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] ufunc = <ufunc 'arcsin'>
[ 213s]
[ 213s] @pytest.mark.parametrize('ufunc', [getattr(np, x) for x in dir(np)
[ 213s] if isinstance(getattr(np, x), np.ufunc)])
[ 213s] def test_ufunc_noncontiguous(ufunc):
[ 213s] '''
[ 213s] Check that contiguous and non-contiguous calls to ufuncs
[ 213s] have the same results for values in range(9)
[ 213s] '''
[ 213s] for typ in ufunc.types:
[ 213s] # types is a list of strings like ii->i
[ 213s] if any(set('O?mM') & set(typ)):
[ 213s] # bool, object, datetime are too irregular for this simple test
[ 213s] continue
[ 213s] inp, out = typ.split('->')
[ 213s] args_c = [np.empty(6, t) for t in inp]
[ 213s] args_n = [np.empty(18, t)[::3] for t in inp]
[ 213s] for a in args_c:
[ 213s] a.flat = range(1,7)
[ 213s] for a in args_n:
[ 213s] a.flat = range(1,7)
[ 213s] with warnings.catch_warnings(record=True):
[ 213s] warnings.filterwarnings("always")
[ 213s] res_c = ufunc(*args_c)
[ 213s] res_n = ufunc(*args_n)
[ 213s] if len(out) == 1:
[ 213s] res_c = (res_c,)
[ 213s] res_n = (res_n,)
[ 213s] for c_ar, n_ar in zip(res_c, res_n):
[ 213s] dt = c_ar.dtype
[ 213s] if np.issubdtype(dt, np.floating):
[ 213s] # for floating point results allow a small fuss in comparisons
[ 213s] # since different algorithms (libm vs. intrinsics) can be used
[ 213s] # for different input strides
[ 213s] res_eps = np.finfo(dt).eps
[ 213s] tol = 2*res_eps
[ 213s] > assert_allclose(res_c, res_n, atol=tol, rtol=tol)
[ 213s]
[ 213s] a = array([1., 2., 3., 4., 5., 6.], dtype=float32)
[ 213s] args_c = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] args_n = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] c_ar = array([1.5707964, nan, nan, nan, nan, nan],
[ 213s] dtype=float32)
[ 213s] dt = dtype('float32')
[ 213s] inp = 'f'
[ 213s] n_ar = array([1.5707964, nan, nan, nan, nan, nan],
[ 213s] dtype=float32)
[ 213s] out = 'f'
[ 213s] res_c = (array([1.5707964, nan, nan, nan, nan, nan],
[ 213s] dtype=float32),)
[ 213s] res_eps = 1.1920929e-07
[ 213s] res_n = (array([1.5707964, nan, nan, nan, nan, nan],
[ 213s] dtype=float32),)
[ 213s] tol = 2.384185791015625e-07
[ 213s] typ = 'f->f'
[ 213s] ufunc = <ufunc 'arcsin'>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_ufunc.py:1946:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[1.5707964, nan, nan, nan, nan, nan]],
[ 213s] dtype=float32)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[1.5707964, nan, nan, nan, nan, nan]],
[ 213s] dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ________________________ TestIsclose.test_masked_arrays ________________________
[ 213s] [gw1] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf2decce8>
[ 213s]
[ 213s] def test_masked_arrays(self):
[ 213s] # Make sure to test the output type when arguments are interchanged.
[ 213s]
[ 213s] x = np.ma.masked_where([True, True, False], np.arange(3))
[ 213s] assert_(type(x) is type(np.isclose(2, x)))
[ 213s] assert_(type(x) is type(np.isclose(x, 2)))
[ 213s]
[ 213s] x = np.ma.masked_where([True, True, False], [np.nan, np.inf, np.nan])
[ 213s] > assert_(type(x) is type(np.isclose(np.inf, x)))
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf2decce8>
[ 213s] x = masked_array(data=[--, --, nan],
[ 213s] mask=[ True, True, False],
[ 213s] fill_value=1e+20)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2211:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] <__array_function__ internals>:5: in isclose
[ 213s] ???
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/numeric.py:2272: in isclose
[ 213s] cond[~finite] = (x[~finite] == y[~finite])
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/core.py:4077: in __eq__
[ 213s] return self._comparison(other, operator.eq)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] self = masked_array(data=[--, --, inf],
[ 213s] mask=[ True, True, False],
[ 213s] fill_value=1e+20)
[ 213s] other = masked_array(data=[--, --, nan],
[ 213s] mask=[ True, True, False],
[ 213s] fill_value=1e+20)
[ 213s] compare = <built-in function eq>
[ 213s]
[ 213s] def _comparison(self, other, compare):
[ 213s] """Compare self with other using operator.eq or operator.ne.
[ 213s]
[ 213s] When either of the elements is masked, the result is masked as well,
[ 213s] but the underlying boolean data are still set, with self and other
[ 213s] considered equal if both are masked, and unequal otherwise.
[ 213s]
[ 213s] For structured arrays, all fields are combined, with masked values
[ 213s] ignored. The result is masked if all fields were masked, with self
[ 213s] and other considered equal only if both were fully masked.
[ 213s] """
[ 213s] omask = getmask(other)
[ 213s] smask = self.mask
[ 213s] mask = mask_or(smask, omask, copy=True)
[ 213s]
[ 213s] odata = getdata(other)
[ 213s] if mask.dtype.names is not None:
[ 213s] # For possibly masked structured arrays we need to be careful,
[ 213s] # since the standard structured array comparison will use all
[ 213s] # fields, masked or not. To avoid masked fields influencing the
[ 213s] # outcome, we set all masked fields in self to other, so they'll
[ 213s] # count as equal. To prepare, we ensure we have the right shape.
[ 213s] broadcast_shape = np.broadcast(self, odata).shape
[ 213s] sbroadcast = np.broadcast_to(self, broadcast_shape, subok=True)
[ 213s] sbroadcast._mask = mask
[ 213s] sdata = sbroadcast.filled(odata)
[ 213s] # Now take care of the mask; the merged mask should have an item
[ 213s] # masked if all fields were masked (in one and/or other).
[ 213s] mask = (mask == np.ones((), mask.dtype))
[ 213s]
[ 213s] else:
[ 213s] # For regular arrays, just use the data as they come.
[ 213s] sdata = self.data
[ 213s]
[ 213s] > check = compare(sdata, odata)
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] compare = <built-in function eq>
[ 213s] mask = array([ True, True, False])
[ 213s] odata = array([nan, inf, nan])
[ 213s] omask = array([ True, True, False])
[ 213s] other = masked_array(data=[--, --, nan],
[ 213s] mask=[ True, True, False],
[ 213s] fill_value=1e+20)
[ 213s] sdata = array([inf, inf, inf])
[ 213s] self = masked_array(data=[--, --, inf],
[ 213s] mask=[ True, True, False],
[ 213s] fill_value=1e+20)
[ 213s] smask = array([ True, True, False])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/core.py:4036: DeprecationWarning
[ 213s] _____________________ TestIsclose.test_ip_isclose_allclose _____________________
[ 213s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf22a26b8>
[ 213s]
[ 213s] def test_ip_isclose_allclose(self):
[ 213s] self.setup()
[ 213s] tests = (self.all_close_tests + self.none_close_tests +
[ 213s] self.some_close_tests)
[ 213s] for (x, y) in tests:
[ 213s] > self.tst_isclose_allclose(x, y)
[ 213s]
[ 213s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf22a26b8>
[ 213s] tests = [([1, 0], [1, 0]), ([1e-08], [0]), ([1], [1.00001001]), (array([ 100, 1000]), array([ 100.001, 1000.01 ])), (array([ 1... 116.00116, 117.00117, 118.00118, 119.00119],
[ 213s] [120.0012 , 121.00121, 122.00122, 123.00123, 124.00124]]])), ...]
[ 213s] x = [nan, 0]
[ 213s] y = [nan, -inf]
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2196:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2179: in tst_isclose_allclose
[ 213s] assert_array_equal(np.isclose(x, y).all(), np.allclose(x, y), msg % (x, y))
[ 213s] <__array_function__ internals>:5: in isclose
[ 213s] ???
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] a = [nan, 0], b = [nan, -inf], rtol = 1e-05, atol = 1e-08, equal_nan = False
[ 213s]
[ 213s] @array_function_dispatch(_isclose_dispatcher)
[ 213s] def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
[ 213s] """
[ 213s] Returns a boolean array where two arrays are element-wise equal within a
[ 213s] tolerance.
[ 213s]
[ 213s] The tolerance values are positive, typically very small numbers. The
[ 213s] relative difference (`rtol` * abs(`b`)) and the absolute difference
[ 213s] `atol` are added together to compare against the absolute difference
[ 213s] between `a` and `b`.
[ 213s]
[ 213s] .. warning:: The default `atol` is not appropriate for comparing numbers
[ 213s] that are much smaller than one (see Notes).
[ 213s]
[ 213s] Parameters
[ 213s] ----------
[ 213s] a, b : array_like
[ 213s] Input arrays to compare.
[ 213s] rtol : float
[ 213s] The relative tolerance parameter (see Notes).
[ 213s] atol : float
[ 213s] The absolute tolerance parameter (see Notes).
[ 213s] equal_nan : bool
[ 213s] Whether to compare NaN's as equal. If True, NaN's in `a` will be
[ 213s] considered equal to NaN's in `b` in the output array.
[ 213s]
[ 213s] Returns
[ 213s] -------
[ 213s] y : array_like
[ 213s] Returns a boolean array of where `a` and `b` are equal within the
[ 213s] given tolerance. If both `a` and `b` are scalars, returns a single
[ 213s] boolean value.
[ 213s]
[ 213s] See Also
[ 213s] --------
[ 213s] allclose
[ 213s]
[ 213s] Notes
[ 213s] -----
[ 213s] .. versionadded:: 1.7.0
[ 213s]
[ 213s] For finite values, isclose uses the following equation to test whether
[ 213s] two floating point values are equivalent.
[ 213s]
[ 213s] absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
[ 213s]
[ 213s] Unlike the built-in `math.isclose`, the above equation is not symmetric
[ 213s] in `a` and `b` -- it assumes `b` is the reference value -- so that
[ 213s] `isclose(a, b)` might be different from `isclose(b, a)`. Furthermore,
[ 213s] the default value of atol is not zero, and is used to determine what
[ 213s] small values should be considered close to zero. The default value is
[ 213s] appropriate for expected values of order unity: if the expected values
[ 213s] are significantly smaller than one, it can result in false positives.
[ 213s] `atol` should be carefully selected for the use case at hand. A zero value
[ 213s] for `atol` will result in `False` if either `a` or `b` is zero.
[ 213s]
[ 213s] Examples
[ 213s] --------
[ 213s] >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
[ 213s] array([False, True])
[ 213s] >>> np.isclose([1.0, np.nan], [1.0, np.nan])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
[ 213s] array([ True, False])
[ 213s] >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
[ 213s] array([False, False])
[ 213s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
[ 213s] array([ True, True])
[ 213s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
[ 213s] array([False, True])
[ 213s] """
[ 213s] def within_tol(x, y, atol, rtol):
[ 213s] with errstate(invalid='ignore'):
[ 213s] return less_equal(abs(x-y), atol + rtol * abs(y))
[ 213s]
[ 213s] x = asanyarray(a)
[ 213s] y = asanyarray(b)
[ 213s]
[ 213s] # Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
[ 213s] # This will cause casting of x later. Also, make sure to allow subclasses
[ 213s] # (e.g., for numpy.ma).
[ 213s] dt = multiarray.result_type(y, 1.)
[ 213s] y = array(y, dtype=dt, copy=False, subok=True)
[ 213s]
[ 213s] xfin = isfinite(x)
[ 213s] yfin = isfinite(y)
[ 213s] if all(xfin) and all(yfin):
[ 213s] return within_tol(x, y, atol, rtol)
[ 213s] else:
[ 213s] finite = xfin & yfin
[ 213s] cond = zeros_like(finite, subok=True)
[ 213s] # Because we're using boolean indexing, x & y must be the same shape.
[ 213s] # Ideally, we'd just do x, y = broadcast_arrays(x, y). It's in
[ 213s] # lib.stride_tricks, though, so we can't import it here.
[ 213s] x = x * ones_like(cond)
[ 213s] y = y * ones_like(cond)
[ 213s] # Avoid subtraction with infinite/nan values...
[ 213s] cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
[ 213s] # Check for equality of infinite values...
[ 213s] > cond[~finite] = (x[~finite] == y[~finite])
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] a = [nan, 0]
[ 213s] atol = 1e-08
[ 213s] b = [nan, -inf]
[ 213s] cond = array([False, False])
[ 213s] dt = dtype('float64')
[ 213s] equal_nan = False
[ 213s] finite = array([False, False])
[ 213s] rtol = 1e-05
[ 213s] within_tol = <function isclose.<locals>.within_tol at 0xf2f92f58>
[ 213s] x = array([nan, 0.])
[ 213s] xfin = array([False, True])
[ 213s] y = array([ nan, -inf])
[ 213s] yfin = array([False, False])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/numeric.py:2272: DeprecationWarning
[ 213s] ______________________ test_ufunc_noncontiguous[arctanh] _______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] ufunc = <ufunc 'arctanh'>
[ 213s]
[ 213s] @pytest.mark.parametrize('ufunc', [getattr(np, x) for x in dir(np)
[ 213s] if isinstance(getattr(np, x), np.ufunc)])
[ 213s] def test_ufunc_noncontiguous(ufunc):
[ 213s] '''
[ 213s] Check that contiguous and non-contiguous calls to ufuncs
[ 213s] have the same results for values in range(9)
[ 213s] '''
[ 213s] for typ in ufunc.types:
[ 213s] # types is a list of strings like ii->i
[ 213s] if any(set('O?mM') & set(typ)):
[ 213s] # bool, object, datetime are too irregular for this simple test
[ 213s] continue
[ 213s] inp, out = typ.split('->')
[ 213s] args_c = [np.empty(6, t) for t in inp]
[ 213s] args_n = [np.empty(18, t)[::3] for t in inp]
[ 213s] for a in args_c:
[ 213s] a.flat = range(1,7)
[ 213s] for a in args_n:
[ 213s] a.flat = range(1,7)
[ 213s] with warnings.catch_warnings(record=True):
[ 213s] warnings.filterwarnings("always")
[ 213s] res_c = ufunc(*args_c)
[ 213s] res_n = ufunc(*args_n)
[ 213s] if len(out) == 1:
[ 213s] res_c = (res_c,)
[ 213s] res_n = (res_n,)
[ 213s] for c_ar, n_ar in zip(res_c, res_n):
[ 213s] dt = c_ar.dtype
[ 213s] if np.issubdtype(dt, np.floating):
[ 213s] # for floating point results allow a small fuss in comparisons
[ 213s] # since different algorithms (libm vs. intrinsics) can be used
[ 213s] # for different input strides
[ 213s] res_eps = np.finfo(dt).eps
[ 213s] tol = 2*res_eps
[ 213s] > assert_allclose(res_c, res_n, atol=tol, rtol=tol)
[ 213s]
[ 213s] a = array([1., 2., 3., 4., 5., 6.], dtype=float32)
[ 213s] args_c = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] args_n = [array([1., 2., 3., 4., 5., 6.], dtype=float32)]
[ 213s] c_ar = array([inf, nan, nan, nan, nan, nan], dtype=float32)
[ 213s] dt = dtype('float32')
[ 213s] inp = 'f'
[ 213s] n_ar = array([inf, nan, nan, nan, nan, nan], dtype=float32)
[ 213s] out = 'f'
[ 213s] res_c = (array([inf, nan, nan, nan, nan, nan], dtype=float32),)
[ 213s] res_eps = 1.1920929e-07
[ 213s] res_n = (array([inf, nan, nan, nan, nan, nan], dtype=float32),)
[ 213s] tol = 2.384185791015625e-07
[ 213s] typ = 'f->f'
[ 213s] ufunc = <ufunc 'arctanh'>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_ufunc.py:1946:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[inf, nan, nan, nan, nan, nan]], dtype=float32)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[inf, nan, nan, nan, nan, nan]], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________________ TestSpecialFloats.test_exp_values _______________________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0xf2f2c688>
[ 213s]
[ 213s] def test_exp_values(self):
[ 213s] x = [np.nan, np.nan, np.inf, 0.]
[ 213s] y = [np.nan, -np.nan, np.inf, -np.inf]
[ 213s] for dt in ['f', 'd', 'g']:
[ 213s] xf = np.array(x, dtype=dt)
[ 213s] yf = np.array(y, dtype=dt)
[ 213s] > assert_equal(np.exp(yf), xf)
[ 213s]
[ 213s] dt = 'f'
[ 213s] self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0xf2f2c688>
[ 213s] x = [nan, nan, inf, 0.0]
[ 213s] xf = array([nan, nan, inf, 0.], dtype=float32)
[ 213s] y = [nan, nan, inf, -inf]
[ 213s] yf = array([ nan, nan, inf, -inf], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:652:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, nan, inf, 0.], dtype=float32)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, nan, inf, 0.], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________________ TestSpecialFloats.test_abs_values _______________________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0xf3282280>
[ 213s]
[ 213s] def test_abs_values(self):
[ 213s] x = [np.nan, np.nan, np.inf, np.inf, 0., 0., 1.0, 1.0]
[ 213s] y = [np.nan, -np.nan, np.inf, -np.inf, 0., -0., -1.0, 1.0]
[ 213s] for dt in ['f', 'd', 'g']:
[ 213s] xf = np.array(x, dtype=dt)
[ 213s] yf = np.array(y, dtype=dt)
[ 213s] > assert_equal(np.abs(yf), xf)
[ 213s]
[ 213s] dt = 'f'
[ 213s] self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0xf3282280>
[ 213s] x = [nan, nan, inf, inf, 0.0, 0.0, ...]
[ 213s] xf = array([nan, nan, inf, inf, 0., 0., 1., 1.], dtype=float32)
[ 213s] y = [nan, nan, inf, -inf, 0.0, -0.0, ...]
[ 213s] yf = array([ nan, nan, inf, -inf, 0., -0., -1., 1.], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:709:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, nan, inf, inf, 0., 0., 1., 1.], dtype=float32)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, nan, inf, inf, 0., 0., 1., 1.], dtype=float32)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________________________ TestIO.test_nan ________________________________
[ 213s] [gw9] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2055bb0>
[ 213s]
[ 213s] def test_nan(self):
[ 213s] > self._check_from(
[ 213s] b"nan +nan -nan NaN nan(foo) +NaN(BAR) -NAN(q_u_u_x_)",
[ 213s] [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
[ 213s] sep=' ')
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2055bb0>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4881:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4872: in _check_from
[ 213s] assert_array_equal(y, value)
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, nan, nan, nan, nan, nan, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, nan, nan, nan, nan, nan, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ___________________ TestIO.test_io_open_unbuffered_fromfile ____________________
[ 213s] [gw2] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3272208>
[ 213s]
[ 213s] def test_io_open_unbuffered_fromfile(self):
[ 213s] # gh-6632
[ 213s] self.x.tofile(self.filename)
[ 213s] with io.open(self.filename, 'rb', buffering=0) as f:
[ 213s] y = np.fromfile(f, dtype=self.dtype)
[ 213s] > assert_array_equal(y, self.x.flat)
[ 213s]
[ 213s] f = <_io.FileIO [closed]>
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3272208>
[ 213s] y = array([0.47170282+0.72142351j, nan+0.j ,
[ 213s] 0.71690674+0.206099j , 0.92662906+0.79214133j,
[ 213s] ...625423j,
[ 213s] 0.49635936+0.36846707j, 0.49771917+0.04316379j,
[ 213s] 0.83839525+0.35313285j, 0.31546631+0.20880257j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4746:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([0.47170282+0.72142351j, nan+0.j ,
[ 213s] 0.71690674+0.206099j , 0.92662906+0.79214133j,
[ 213s] ...625423j,
[ 213s] 0.49635936+0.36846707j, 0.49771917+0.04316379j,
[ 213s] 0.83839525+0.35313285j, 0.31546631+0.20880257j])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([0.47170282+0.72142351j, nan+0.j ,
[ 213s] 0.71690674+0.206099j , 0.92662906+0.79214133j,
[ 213s] ...625423j,
[ 213s] 0.49635936+0.36846707j, 0.49771917+0.04316379j,
[ 213s] 0.83839525+0.35313285j, 0.31546631+0.20880257j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] __________________________ TestIO.test_roundtrip_repr __________________________
[ 213s] [gw0] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf0eef880>
[ 213s]
[ 213s] def test_roundtrip_repr(self):
[ 213s] x = self.x.real.ravel()
[ 213s] s = "@".join(map(repr, x))
[ 213s] y = np.fromstring(s, sep="@")
[ 213s] > assert_array_equal(x, y)
[ 213s]
[ 213s] s = '0.14068809208442334@nan@0.8481262402607952@0.90907717248005@inf@0.3024517210126648@0.8612981885220966@-inf@0.24302306...@0.2808156171636934@0.06102595417409118@0.7649244982264787@0.20459037784602596@0.029812197702149934@0.9964727765288109'
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf0eef880>
[ 213s] x = array([0.14068809, nan, 0.84812624, 0.90907717, inf,
[ 213s] 0.30245172, 0.86129819, -inf, 0.243023... 0.48398921, 0.03735986, 0.54645802, 0.28081562, 0.06102595,
[ 213s] 0.7649245 , 0.20459038, 0.0298122 , 0.99647278])
[ 213s] y = array([0.14068809, nan, 0.84812624, 0.90907717, inf,
[ 213s] 0.30245172, 0.86129819, -inf, 0.243023... 0.48398921, 0.03735986, 0.54645802, 0.28081562, 0.06102595,
[ 213s] 0.7649245 , 0.20459038, 0.0298122 , 0.99647278])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4727:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([0.14068809, nan, 0.84812624, 0.90907717, inf,
[ 213s] 0.30245172, 0.86129819, -inf, 0.243023... 0.48398921, 0.03735986, 0.54645802, 0.28081562, 0.06102595,
[ 213s] 0.7649245 , 0.20459038, 0.0298122 , 0.99647278])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([0.14068809, nan, 0.84812624, 0.90907717, inf,
[ 213s] 0.30245172, 0.86129819, -inf, 0.243023... 0.48398921, 0.03735986, 0.54645802, 0.28081562, 0.06102595,
[ 213s] 0.7649245 , 0.20459038, 0.0298122 , 0.99647278])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________ TestStatistic.test_zero_stat_length_valid[mean] ________________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_arraypad.TestStatistic object at 0xf27e2520>
[ 213s] mode = 'mean'
[ 213s]
[ 213s] @pytest.mark.filterwarnings("ignore:Mean of empty slice:RuntimeWarning")
[ 213s] @pytest.mark.filterwarnings(
[ 213s] "ignore:invalid value encountered in (true_divide|double_scalars):"
[ 213s] "RuntimeWarning"
[ 213s] )
[ 213s] @pytest.mark.parametrize("mode", ["mean", "median"])
[ 213s] def test_zero_stat_length_valid(self, mode):
[ 213s] arr = np.pad([1., 2.], (1, 2), mode, stat_length=0)
[ 213s] expected = np.array([np.nan, 1., 2., np.nan, np.nan])
[ 213s] > assert_equal(arr, expected)
[ 213s]
[ 213s] arr = array([nan, 1., 2., nan, nan])
[ 213s] expected = array([nan, 1., 2., nan, nan])
[ 213s] mode = 'mean'
[ 213s] self = <numpy.lib.tests.test_arraypad.TestStatistic object at 0xf27e2520>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_arraypad.py:486:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, 1., 2., nan, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, 1., 2., nan, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________________________ TestIO.test_locale ______________________________
[ 213s] [gw9] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2102220>
[ 213s]
[ 213s] def test_locale(self):
[ 213s] with CommaDecimalPointLocale():
[ 213s] self.test_numbers()
[ 213s] > self.test_nan()
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2102220>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4992:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4881: in test_nan
[ 213s] self._check_from(
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4872: in _check_from
[ 213s] assert_array_equal(y, value)
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, nan, nan, nan, nan, nan, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, nan, nan, nan, nan, nan, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________ TestStatistic.test_zero_stat_length_valid[median] _______________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_arraypad.TestStatistic object at 0xf2f18298>
[ 213s] mode = 'median'
[ 213s]
[ 213s] @pytest.mark.filterwarnings("ignore:Mean of empty slice:RuntimeWarning")
[ 213s] @pytest.mark.filterwarnings(
[ 213s] "ignore:invalid value encountered in (true_divide|double_scalars):"
[ 213s] "RuntimeWarning"
[ 213s] )
[ 213s] @pytest.mark.parametrize("mode", ["mean", "median"])
[ 213s] def test_zero_stat_length_valid(self, mode):
[ 213s] arr = np.pad([1., 2.], (1, 2), mode, stat_length=0)
[ 213s] expected = np.array([np.nan, 1., 2., np.nan, np.nan])
[ 213s] > assert_equal(arr, expected)
[ 213s]
[ 213s] arr = array([nan, 1., 2., nan, nan])
[ 213s] expected = array([nan, 1., 2., nan, nan])
[ 213s] mode = 'median'
[ 213s] self = <numpy.lib.tests.test_arraypad.TestStatistic object at 0xf2f18298>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_arraypad.py:486:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([nan, 1., 2., nan, nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([nan, 1., 2., nan, nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] __________________________ TestIO.test_roundtrip_file __________________________
[ 213s] [gw10] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf33bb628>
[ 213s]
[ 213s] def test_roundtrip_file(self):
[ 213s] f = open(self.filename, 'wb')
[ 213s] self.x.tofile(f)
[ 213s] f.close()
[ 213s] # NB. doesn't work with flush+seek, due to use of C stdio
[ 213s] f = open(self.filename, 'rb')
[ 213s] y = np.fromfile(f, dtype=self.dtype)
[ 213s] f.close()
[ 213s] > assert_array_equal(y, self.x.flat)
[ 213s]
[ 213s] f = <_io.BufferedReader name='/tmp/tmpvpnd2b3p/tmpen4xw_xl'>
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf33bb628>
[ 213s] y = array([0.92903119+0.87911146j, nan+0.j ,
[ 213s] 0.16350872+0.83675271j, 0.02036702+0.79422447j,
[ 213s] ...505032j,
[ 213s] 0.09962475+0.21165761j, 0.29597002+0.32687325j,
[ 213s] 0.3946944 +0.81077573j, 0.78988382+0.71696815j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4684:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([0.92903119+0.87911146j, nan+0.j ,
[ 213s] 0.16350872+0.83675271j, 0.02036702+0.79422447j,
[ 213s] ...505032j,
[ 213s] 0.09962475+0.21165761j, 0.29597002+0.32687325j,
[ 213s] 0.3946944 +0.81077573j, 0.78988382+0.71696815j])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([0.92903119+0.87911146j, nan+0.j ,
[ 213s] 0.16350872+0.83675271j, 0.02036702+0.79422447j,
[ 213s] ...505032j,
[ 213s] 0.09962475+0.21165761j, 0.29597002+0.32687325j,
[ 213s] 0.3946944 +0.81077573j, 0.78988382+0.71696815j])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________ TestInterp.test_non_finite_inf[complex-real] _________________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1c604c0>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s]
[ 213s] def test_non_finite_inf(self, sc):
[ 213s] """ Test that interp between opposite infs gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, +np.inf], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1c604c0>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2448:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________ TestInterp.test_non_finite_inf[complex-imag] _________________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1149358>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s]
[ 213s] def test_non_finite_inf(self, sc):
[ 213s] """ Test that interp between opposite infs gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, +np.inf], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1149358>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2448:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________ TestInterp.test_non_finite_inf[complex-both] _________________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1c3c3a0>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s]
[ 213s] def test_non_finite_inf(self, sc):
[ 213s] """ Test that interp between opposite infs gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, +np.inf], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1c3c3a0>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2448:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ____________________________ TestMethods.test_sort _____________________________
[ 213s] [gw13] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestMethods object at 0xf210e940>
[ 213s]
[ 213s] def test_sort(self):
[ 213s] # test ordering for floats and complex containing nans. It is only
[ 213s] # necessary to check the less-than comparison, so sorts that
[ 213s] # only follow the insertion sort path are sufficient. We only
[ 213s] # test doubles and complex doubles as the logic is the same.
[ 213s]
[ 213s] # check doubles
[ 213s] msg = "Test real sort order with nans"
[ 213s] a = np.array([np.nan, 1, 0])
[ 213s] b = np.sort(a)
[ 213s] > assert_equal(b, a[::-1], msg)
[ 213s]
[ 213s] a = array([nan, 1., 0.])
[ 213s] b = array([ 0., 1., nan])
[ 213s] msg = 'Test real sort order with nans'
[ 213s] self = <numpy.core.tests.test_multiarray.TestMethods object at 0xf210e940>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:1701:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([ 0., 1., nan])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([ 0., 1., nan])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________ TestInterp.test_non_finite_behavior_exact_x __________________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf27113d0>
[ 213s]
[ 213s] def test_non_finite_behavior_exact_x(self):
[ 213s] x = [1, 2, 2.5, 3, 4]
[ 213s] xp = [1, 2, 3, 4]
[ 213s] fp = [1, 2, np.inf, 4]
[ 213s] assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.inf, np.inf, 4])
[ 213s] fp = [1, 2, np.nan, 4]
[ 213s] > assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.nan, np.nan, 4])
[ 213s]
[ 213s] fp = [1, 2, nan, 4]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf27113d0>
[ 213s] x = [1, 2, 2.5, 3, 4]
[ 213s] xp = [1, 2, 3, 4]
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2422:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([ 1., 2., nan, nan, 4.])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([ 1., 2., nan, nan, 4.])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________________ TestSelect.test_return_dtype _________________________
[ 213s] [gw5] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestSelect object at 0xf28ae658>
[ 213s]
[ 213s] def test_return_dtype(self):
[ 213s] assert_equal(select(self.conditions, self.choices, 1j).dtype,
[ 213s] np.complex_)
[ 213s] # But the conditions need to be stronger then the scalar default
[ 213s] # if it is scalar.
[ 213s] choices = [choice.astype(np.int8) for choice in self.choices]
[ 213s] assert_equal(select(self.conditions, choices).dtype, np.int8)
[ 213s]
[ 213s] d = np.array([1, 2, 3, np.nan, 5, 7])
[ 213s] m = np.isnan(d)
[ 213s] > assert_equal(select([m], [d]), [0, 0, 0, np.nan, 0, 0])
[ 213s]
[ 213s] choices = [array([1, 2, 3], dtype=int8), array([4, 5, 6], dtype=int8), array([7, 8, 9], dtype=int8)]
[ 213s] d = array([ 1., 2., 3., nan, 5., 7.])
[ 213s] m = array([False, False, False, True, False, False])
[ 213s] self = <numpy.lib.tests.test_function_base.TestSelect object at 0xf28ae658>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:423:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([ 0., 0., 0., nan, 0., 0.])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([ 0., 0., 0., nan, 0., 0.])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _____________ TestInterp.test_non_finite_half_inf_xf[complex-real] _____________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1609088>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s]
[ 213s] def test_non_finite_half_inf_xf(self, sc):
[ 213s] """ Test that interp where both axes have a bound at inf gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, 1], sc([-np.inf, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1609088>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2457:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________ TestInterp.test_non_finite_any_nan[complex-real] _______________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf24ed310>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s]
[ 213s] def test_non_finite_any_nan(self, sc):
[ 213s] """ test that nans are propagated """
[ 213s] > assert_equal(np.interp(0.5, [np.nan, 1], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268df0>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf24ed310>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2441:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+0.j)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _____________ TestInterp.test_non_finite_half_inf_xf[complex-imag] _____________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1149568>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s]
[ 213s] def test_non_finite_half_inf_xf(self, sc):
[ 213s] """ Test that interp where both axes have a bound at inf gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, 1], sc([-np.inf, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf1149568>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2457:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ______________________ TestFromTxt.test_missing_with_tabs ______________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xef1d3580>
[ 213s]
[ 213s] def test_missing_with_tabs(self):
[ 213s] # Test w/ a delimiter tab
[ 213s] txt = "1\t2\t3\n\t2\t\n1\t\t3"
[ 213s] test = np.genfromtxt(TextIO(txt), delimiter="\t",
[ 213s] usemask=True,)
[ 213s] ctrl_d = np.array([(1, 2, 3), (np.nan, 2, np.nan), (1, np.nan, 3)],)
[ 213s] ctrl_m = np.array([(0, 0, 0), (1, 0, 1), (0, 1, 0)], dtype=bool)
[ 213s] > assert_equal(test.data, ctrl_d)
[ 213s]
[ 213s] ctrl_d = array([[ 1., 2., 3.],
[ 213s] [nan, 2., nan],
[ 213s] [ 1., nan, 3.]])
[ 213s] ctrl_m = array([[False, False, False],
[ 213s] [ True, False, True],
[ 213s] [False, True, False]])
[ 213s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xef1d3580>
[ 213s] test = masked_array(
[ 213s] data=[[1.0, 2.0, 3.0],
[ 213s] [--, 2.0, --],
[ 213s] [1.0, --, 3.0]],
[ 213s] mask=[[False, False, False],
[ 213s] [ True, False, True],
[ 213s] [False, True, False]],
[ 213s] fill_value=1e+20)
[ 213s] txt = '1\t2\t3\n\t2\t\n1\t\t3'
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_io.py:1622:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:146: in assert_equal
[ 213s] return assert_array_equal(actual, desired, err_msg)
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:227: in assert_array_equal
[ 213s] assert_array_compare(operator.__eq__, x, y,
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:215: in assert_array_compare
[ 213s] return np.testing.assert_array_compare(comparison,
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[ 1., 2., 3.],
[ 213s] [nan, 2., nan],
[ 213s] [ 1., nan, 3.]])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[ 1., 2., 3.],
[ 213s] [nan, 2., nan],
[ 213s] [ 1., nan, 3.]])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________ TestInterp.test_non_finite_any_nan[complex-imag] _______________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf25e2520>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s]
[ 213s] def test_non_finite_any_nan(self, sc):
[ 213s] """ test that nans are propagated """
[ 213s] > assert_equal(np.interp(0.5, [np.nan, 1], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e38>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf25e2520>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2441:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(0.+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] ____________________ TestNanFunctions_SumProd.test_mutation ____________________
[ 213s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_SumProd object at 0xf2b148b0>
[ 213s]
[ 213s] def test_mutation(self):
[ 213s] # Check that passed array is not modified.
[ 213s] ndat = _ndat.copy()
[ 213s] for f in self.nanfuncs:
[ 213s] f(ndat)
[ 213s] > assert_equal(ndat, _ndat)
[ 213s]
[ 213s] f = <function nansum at 0xddf56898>
[ 213s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_SumProd object at 0xf2b148b0>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:317:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _____________ TestInterp.test_non_finite_half_inf_xf[complex-both] _____________
[ 213s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf19390a0>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s]
[ 213s] def test_non_finite_half_inf_xf(self, sc):
[ 213s] """ Test that interp where both axes have a bound at inf gives nan """
[ 213s] > assert_equal(np.interp(0.5, [-np.inf, 1], sc([-np.inf, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf19390a0>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2457:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _______________ TestInterp.test_non_finite_any_nan[complex-both] _______________
[ 213s] [gw7] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf2c3e418>
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s]
[ 213s] def test_non_finite_any_nan(self, sc):
[ 213s] """ test that nans are propagated """
[ 213s] > assert_equal(np.interp(0.5, [np.nan, 1], sc([ 0, 10])), sc(np.nan))
[ 213s]
[ 213s] sc = <function TestInterp.<lambda> at 0xf4268e80>
[ 213s] self = <numpy.lib.tests.test_function_base.TestInterp object at 0xf2c3e418>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2441:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array(nan+nanj)
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] __________________ TestNanFunctions_CumSumProd.test_mutation ___________________
[ 213s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_CumSumProd object at 0xf29951d8>
[ 213s]
[ 213s] def test_mutation(self):
[ 213s] # Check that passed array is not modified.
[ 213s] ndat = _ndat.copy()
[ 213s] for f in self.nanfuncs:
[ 213s] f(ndat)
[ 213s] > assert_equal(ndat, _ndat)
[ 213s]
[ 213s] f = <function nancumsum at 0xddf56a48>
[ 213s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_CumSumProd object at 0xf29951d8>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:317:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 213s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 213s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 213s] _________________________ TestFromTxt.test_withmissing _________________________
[ 213s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xeef15688>
[ 213s]
[ 213s] def test_withmissing(self):
[ 213s] data = TextIO('A,B\n0,1\n2,N/A')
[ 213s] kwargs = dict(delimiter=",", missing_values="N/A", names=True)
[ 213s] test = np.genfromtxt(data, dtype=None, usemask=True, **kwargs)
[ 213s] control = ma.array([(0, 1), (2, -1)],
[ 213s] mask=[(False, False), (False, True)],
[ 213s] dtype=[('A', int), ('B', int)])
[ 213s] assert_equal(test, control)
[ 213s] assert_equal(test.mask, control.mask)
[ 213s] #
[ 213s] data.seek(0)
[ 213s] > test = np.genfromtxt(data, usemask=True, **kwargs)
[ 213s]
[ 213s] control = masked_array(data=[(0, 1), (2, --)],
[ 213s] mask=[(False, False), (False, True)],
[ 213s] fill_value=(999999, 999999),
[ 213s] dtype=[('A', '<i4'), ('B', '<i4')])
[ 213s] data = <numpy.lib.tests.test_io.TextIO object at 0xef2c04d8>
[ 213s] kwargs = {'delimiter': ',', 'missing_values': 'N/A', 'names': True}
[ 213s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xeef15688>
[ 213s] test = masked_array(data=[(0, 1), (2, --)],
[ 213s] mask=[(False, False), (False, True)],
[ 213s] fill_value=(999999, 999999),
[ 213s] dtype=[('A', '<i4'), ('B', '<i4')])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_io.py:1720:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] fname = <numpy.lib.tests.test_io.TextIO object at 0xef2c04d8>
[ 213s] dtype = dtype([('A', '<f8'), ('B', '<f8')]), comments = '#', delimiter = ','
[ 213s] skip_header = 0, skip_footer = 0
[ 213s] converters = [<numpy.lib._iotools.StringConverter object at 0xef3762e0>, <numpy.lib._iotools.StringConverter object at 0xef3762c8>]
[ 213s] missing_values = [nan], filling_values = [None, None], usecols = None
[ 213s] names = ('A', 'B'), excludelist = None
[ 213s] deletechars = " !#$%&'()*+,-./:;<=>?@[\\]^{|}~", replace_space = '_'
[ 213s] autostrip = False, case_sensitive = True, defaultfmt = 'f%i', unpack = None
[ 213s] usemask = True, loose = True, invalid_raise = True, max_rows = None
[ 213s] encoding = None
[ 213s]
[ 213s] @set_module('numpy')
[ 213s] def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
[ 213s] skip_header=0, skip_footer=0, converters=None,
[ 213s] missing_values=None, filling_values=None, usecols=None,
[ 213s] names=None, excludelist=None,
[ 213s] deletechars=''.join(sorted(NameValidator.defaultdeletechars)),
[ 213s] replace_space='_', autostrip=False, case_sensitive=True,
[ 213s] defaultfmt="f%i", unpack=None, usemask=False, loose=True,
[ 213s] invalid_raise=True, max_rows=None, encoding='bytes'):
[ 213s] """
[ 213s] Load data from a text file, with missing values handled as specified.
[ 213s]
[ 213s] Each line past the first `skip_header` lines is split at the `delimiter`
[ 213s] character, and characters following the `comments` character are discarded.
[ 213s]
[ 213s] Parameters
[ 213s] ----------
[ 213s] fname : file, str, pathlib.Path, list of str, generator
[ 213s] File, filename, list, or generator to read. If the filename
[ 213s] extension is `.gz` or `.bz2`, the file is first decompressed. Note
[ 213s] that generators must return byte strings. The strings
[ 213s] in a list or produced by a generator are treated as lines.
[ 213s] dtype : dtype, optional
[ 213s] Data type of the resulting array.
[ 213s] If None, the dtypes will be determined by the contents of each
[ 213s] column, individually.
[ 213s] comments : str, optional
[ 213s] The character used to indicate the start of a comment.
[ 213s] All the characters occurring on a line after a comment are discarded
[ 213s] delimiter : str, int, or sequence, optional
[ 213s] The string used to separate values. By default, any consecutive
[ 213s] whitespaces act as delimiter. An integer or sequence of integers
[ 213s] can also be provided as width(s) of each field.
[ 213s] skiprows : int, optional
[ 213s] `skiprows` was removed in numpy 1.10. Please use `skip_header` instead.
[ 213s] skip_header : int, optional
[ 213s] The number of lines to skip at the beginning of the file.
[ 213s] skip_footer : int, optional
[ 213s] The number of lines to skip at the end of the file.
[ 213s] converters : variable, optional
[ 213s] The set of functions that convert the data of a column to a value.
[ 213s] The converters can also be used to provide a default value
[ 213s] for missing data: ``converters = {3: lambda s: float(s or 0)}``.
[ 213s] missing : variable, optional
[ 213s] `missing` was removed in numpy 1.10. Please use `missing_values`
[ 213s] instead.
[ 213s] missing_values : variable, optional
[ 213s] The set of strings corresponding to missing data.
[ 213s] filling_values : variable, optional
[ 213s] The set of values to be used as default when the data are missing.
[ 213s] usecols : sequence, optional
[ 213s] Which columns to read, with 0 being the first. For example,
[ 213s] ``usecols = (1, 4, 5)`` will extract the 2nd, 5th and 6th columns.
[ 213s] names : {None, True, str, sequence}, optional
[ 213s] If `names` is True, the field names are read from the first line after
[ 213s] the first `skip_header` lines. This line can optionally be proceeded
[ 213s] by a comment delimiter. If `names` is a sequence or a single-string of
[ 213s] comma-separated names, the names will be used to define the field names
[ 213s] in a structured dtype. If `names` is None, the names of the dtype
[ 213s] fields will be used, if any.
[ 213s] excludelist : sequence, optional
[ 213s] A list of names to exclude. This list is appended to the default list
[ 213s] ['return','file','print']. Excluded names are appended an underscore:
[ 213s] for example, `file` would become `file_`.
[ 213s] deletechars : str, optional
[ 213s] A string combining invalid characters that must be deleted from the
[ 213s] names.
[ 213s] defaultfmt : str, optional
[ 213s] A format used to define default field names, such as "f%i" or "f_%02i".
[ 213s] autostrip : bool, optional
[ 213s] Whether to automatically strip white spaces from the variables.
[ 213s] replace_space : char, optional
[ 213s] Character(s) used in replacement of white spaces in the variables
[ 213s] names. By default, use a '_'.
[ 213s] case_sensitive : {True, False, 'upper', 'lower'}, optional
[ 213s] If True, field names are case sensitive.
[ 213s] If False or 'upper', field names are converted to upper case.
[ 213s] If 'lower', field names are converted to lower case.
[ 213s] unpack : bool, optional
[ 213s] If True, the returned array is transposed, so that arguments may be
[ 213s] unpacked using ``x, y, z = loadtxt(...)``
[ 213s] usemask : bool, optional
[ 213s] If True, return a masked array.
[ 213s] If False, return a regular array.
[ 213s] loose : bool, optional
[ 213s] If True, do not raise errors for invalid values.
[ 213s] invalid_raise : bool, optional
[ 213s] If True, an exception is raised if an inconsistency is detected in the
[ 213s] number of columns.
[ 213s] If False, a warning is emitted and the offending lines are skipped.
[ 213s] max_rows : int, optional
[ 213s] The maximum number of rows to read. Must not be used with skip_footer
[ 213s] at the same time. If given, the value must be at least 1. Default is
[ 213s] to read the entire file.
[ 213s]
[ 213s] .. versionadded:: 1.10.0
[ 213s] encoding : str, optional
[ 213s] Encoding used to decode the inputfile. Does not apply when `fname` is
[ 213s] a file object. The special value 'bytes' enables backward compatibility
[ 213s] workarounds that ensure that you receive byte arrays when possible
[ 213s] and passes latin1 encoded strings to converters. Override this value to
[ 213s] receive unicode arrays and pass strings as input to converters. If set
[ 213s] to None the system default is used. The default value is 'bytes'.
[ 213s]
[ 213s] .. versionadded:: 1.14.0
[ 213s]
[ 213s] Returns
[ 213s] -------
[ 213s] out : ndarray
[ 213s] Data read from the text file. If `usemask` is True, this is a
[ 213s] masked array.
[ 213s]
[ 213s] See Also
[ 213s] --------
[ 213s] numpy.loadtxt : equivalent function when no data is missing.
[ 213s]
[ 213s] Notes
[ 213s] -----
[ 213s] * When spaces are used as delimiters, or when no delimiter has been given
[ 213s] as input, there should not be any missing data between two fields.
[ 213s] * When the variables are named (either by a flexible dtype or with `names`,
[ 213s] there must not be any header in the file (else a ValueError
[ 213s] exception is raised).
[ 213s] * Individual values are not stripped of spaces by default.
[ 213s] When using a custom converter, make sure the function does remove spaces.
[ 213s]
[ 213s] References
[ 213s] ----------
[ 213s] .. [1] NumPy User Guide, section `I/O with NumPy
[ 213s] <https://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html>`_.
[ 213s]
[ 213s] Examples
[ 213s] ---------
[ 213s] >>> from io import StringIO
[ 213s] >>> import numpy as np
[ 213s]
[ 213s] Comma delimited file with mixed dtype
[ 213s]
[ 213s] >>> s = StringIO(u"1,1.3,abcde")
[ 213s] >>> data = np.genfromtxt(s, dtype=[('myint','i8'),('myfloat','f8'),
[ 213s] ... ('mystring','S5')], delimiter=",")
[ 213s] >>> data
[ 213s] array((1, 1.3, b'abcde'),
[ 213s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 213s]
[ 213s] Using dtype = None
[ 213s]
[ 213s] >>> _ = s.seek(0) # needed for StringIO example only
[ 213s] >>> data = np.genfromtxt(s, dtype=None,
[ 213s] ... names = ['myint','myfloat','mystring'], delimiter=",")
[ 213s] >>> data
[ 213s] array((1, 1.3, b'abcde'),
[ 213s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 213s]
[ 213s] Specifying dtype and names
[ 213s]
[ 213s] >>> _ = s.seek(0)
[ 213s] >>> data = np.genfromtxt(s, dtype="i8,f8,S5",
[ 213s] ... names=['myint','myfloat','mystring'], delimiter=",")
[ 213s] >>> data
[ 213s] array((1, 1.3, b'abcde'),
[ 213s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 213s]
[ 213s] An example with fixed-width columns
[ 213s]
[ 213s] >>> s = StringIO(u"11.3abcde")
[ 213s] >>> data = np.genfromtxt(s, dtype=None, names=['intvar','fltvar','strvar'],
[ 213s] ... delimiter=[1,3,5])
[ 213s] >>> data
[ 213s] array((1, 1.3, b'abcde'),
[ 213s] dtype=[('intvar', '<i8'), ('fltvar', '<f8'), ('strvar', 'S5')])
[ 213s]
[ 213s] An example to show comments
[ 213s]
[ 213s] >>> f = StringIO('''
[ 213s] ... text,# of chars
[ 213s] ... hello world,11
[ 213s] ... numpy,5''')
[ 213s] >>> np.genfromtxt(f, dtype='S12,S12', delimiter=',')
[ 213s] array([(b'text', b''), (b'hello world', b'11'), (b'numpy', b'5')],
[ 213s] dtype=[('f0', 'S12'), ('f1', 'S12')])
[ 213s]
[ 213s] """
[ 213s] if max_rows is not None:
[ 213s] if skip_footer:
[ 213s] raise ValueError(
[ 213s] "The keywords 'skip_footer' and 'max_rows' can not be "
[ 213s] "specified at the same time.")
[ 213s] if max_rows < 1:
[ 213s] raise ValueError("'max_rows' must be at least 1.")
[ 213s]
[ 213s] if usemask:
[ 213s] from numpy.ma import MaskedArray, make_mask_descr
[ 213s] # Check the input dictionary of converters
[ 213s] user_converters = converters or {}
[ 213s] if not isinstance(user_converters, dict):
[ 213s] raise TypeError(
[ 213s] "The input argument 'converter' should be a valid dictionary "
[ 213s] "(got '%s' instead)" % type(user_converters))
[ 213s]
[ 213s] if encoding == 'bytes':
[ 213s] encoding = None
[ 213s] byte_converters = True
[ 213s] else:
[ 213s] byte_converters = False
[ 213s]
[ 213s] # Initialize the filehandle, the LineSplitter and the NameValidator
[ 213s] try:
[ 213s] if isinstance(fname, os_PathLike):
[ 213s] fname = os_fspath(fname)
[ 213s] if isinstance(fname, basestring):
[ 213s] fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)
[ 213s] fid_ctx = contextlib.closing(fid)
[ 213s] else:
[ 213s] fid = fname
[ 213s] fid_ctx = contextlib_nullcontext(fid)
[ 213s] fhd = iter(fid)
[ 213s] except TypeError:
[ 213s] raise TypeError(
[ 213s] "fname must be a string, filehandle, list of strings, "
[ 213s] "or generator. Got %s instead." % type(fname))
[ 213s]
[ 213s] with fid_ctx:
[ 213s] split_line = LineSplitter(delimiter=delimiter, comments=comments,
[ 213s] autostrip=autostrip, encoding=encoding)
[ 213s] validate_names = NameValidator(excludelist=excludelist,
[ 213s] deletechars=deletechars,
[ 213s] case_sensitive=case_sensitive,
[ 213s] replace_space=replace_space)
[ 213s]
[ 213s] # Skip the first `skip_header` rows
[ 213s] try:
[ 213s] for i in range(skip_header):
[ 213s] next(fhd)
[ 213s]
[ 213s] # Keep on until we find the first valid values
[ 213s] first_values = None
[ 213s]
[ 213s] while not first_values:
[ 213s] first_line = _decode_line(next(fhd), encoding)
[ 213s] if (names is True) and (comments is not None):
[ 213s] if comments in first_line:
[ 213s] first_line = (
[ 213s] ''.join(first_line.split(comments)[1:]))
[ 213s] first_values = split_line(first_line)
[ 213s] except StopIteration:
[ 213s] # return an empty array if the datafile is empty
[ 213s] first_line = ''
[ 213s] first_values = []
[ 213s] warnings.warn('genfromtxt: Empty input file: "%s"' % fname, stacklevel=2)
[ 213s]
[ 213s] # Should we take the first values as names ?
[ 213s] if names is True:
[ 213s] fval = first_values[0].strip()
[ 213s] if comments is not None:
[ 213s] if fval in comments:
[ 213s] del first_values[0]
[ 213s]
[ 213s] # Check the columns to use: make sure `usecols` is a list
[ 213s] if usecols is not None:
[ 213s] try:
[ 213s] usecols = [_.strip() for _ in usecols.split(",")]
[ 213s] except AttributeError:
[ 213s] try:
[ 213s] usecols = list(usecols)
[ 213s] except TypeError:
[ 213s] usecols = [usecols, ]
[ 213s] nbcols = len(usecols or first_values)
[ 213s]
[ 213s] # Check the names and overwrite the dtype.names if needed
[ 213s] if names is True:
[ 213s] names = validate_names([str(_.strip()) for _ in first_values])
[ 213s] first_line = ''
[ 213s] elif _is_string_like(names):
[ 213s] names = validate_names([_.strip() for _ in names.split(',')])
[ 213s] elif names:
[ 213s] names = validate_names(names)
[ 213s] # Get the dtype
[ 213s] if dtype is not None:
[ 213s] dtype = easy_dtype(dtype, defaultfmt=defaultfmt, names=names,
[ 213s] excludelist=excludelist,
[ 213s] deletechars=deletechars,
[ 213s] case_sensitive=case_sensitive,
[ 213s] replace_space=replace_space)
[ 213s] # Make sure the names is a list (for 2.5)
[ 213s] if names is not None:
[ 213s] names = list(names)
[ 213s]
[ 213s] if usecols:
[ 213s] for (i, current) in enumerate(usecols):
[ 213s] # if usecols is a list of names, convert to a list of indices
[ 213s] if _is_string_like(current):
[ 213s] usecols[i] = names.index(current)
[ 213s] elif current < 0:
[ 213s] usecols[i] = current + len(first_values)
[ 213s] # If the dtype is not None, make sure we update it
[ 213s] if (dtype is not None) and (len(dtype) > nbcols):
[ 213s] descr = dtype.descr
[ 213s] dtype = np.dtype([descr[_] for _ in usecols])
[ 213s] names = list(dtype.names)
[ 213s] # If `names` is not None, update the names
[ 213s] elif (names is not None) and (len(names) > nbcols):
[ 213s] names = [names[_] for _ in usecols]
[ 213s] elif (names is not None) and (dtype is not None):
[ 213s] names = list(dtype.names)
[ 213s]
[ 213s] # Process the missing values ...............................
[ 213s] # Rename missing_values for convenience
[ 213s] user_missing_values = missing_values or ()
[ 213s] if isinstance(user_missing_values, bytes):
[ 213s] user_missing_values = user_missing_values.decode('latin1')
[ 213s]
[ 213s] # Define the list of missing_values (one column: one list)
[ 213s] missing_values = [list(['']) for _ in range(nbcols)]
[ 213s]
[ 213s] # We have a dictionary: process it field by field
[ 213s] if isinstance(user_missing_values, dict):
[ 213s] # Loop on the items
[ 213s] for (key, val) in user_missing_values.items():
[ 213s] # Is the key a string ?
[ 213s] if _is_string_like(key):
[ 213s] try:
[ 213s] # Transform it into an integer
[ 213s] key = names.index(key)
[ 213s] except ValueError:
[ 213s] # We couldn't find it: the name must have been dropped
[ 213s] continue
[ 213s] # Redefine the key as needed if it's a column number
[ 213s] if usecols:
[ 213s] try:
[ 213s] key = usecols.index(key)
[ 213s] except ValueError:
[ 213s] pass
[ 213s] # Transform the value as a list of string
[ 213s] if isinstance(val, (list, tuple)):
[ 213s] val = [str(_) for _ in val]
[ 213s] else:
[ 213s] val = [str(val), ]
[ 213s] # Add the value(s) to the current list of missing
[ 213s] if key is None:
[ 213s] # None acts as default
[ 213s] for miss in missing_values:
[ 213s] miss.extend(val)
[ 213s] else:
[ 213s] missing_values[key].extend(val)
[ 213s] # We have a sequence : each item matches a column
[ 213s] elif isinstance(user_missing_values, (list, tuple)):
[ 213s] for (value, entry) in zip(user_missing_values, missing_values):
[ 213s] value = str(value)
[ 213s] if value not in entry:
[ 213s] entry.append(value)
[ 213s] # We have a string : apply it to all entries
[ 213s] elif isinstance(user_missing_values, basestring):
[ 213s] user_value = user_missing_values.split(",")
[ 213s] for entry in missing_values:
[ 213s] entry.extend(user_value)
[ 213s] # We have something else: apply it to all entries
[ 213s] else:
[ 213s] for entry in missing_values:
[ 213s] entry.extend([str(user_missing_values)])
[ 213s]
[ 213s] # Process the filling_values ...............................
[ 213s] # Rename the input for convenience
[ 213s] user_filling_values = filling_values
[ 213s] if user_filling_values is None:
[ 213s] user_filling_values = []
[ 213s] # Define the default
[ 213s] filling_values = [None] * nbcols
[ 213s] # We have a dictionary : update each entry individually
[ 213s] if isinstance(user_filling_values, dict):
[ 213s] for (key, val) in user_filling_values.items():
[ 213s] if _is_string_like(key):
[ 213s] try:
[ 213s] # Transform it into an integer
[ 213s] key = names.index(key)
[ 213s] except ValueError:
[ 213s] # We couldn't find it: the name must have been dropped,
[ 213s] continue
[ 213s] # Redefine the key if it's a column number and usecols is defined
[ 213s] if usecols:
[ 213s] try:
[ 213s] key = usecols.index(key)
[ 213s] except ValueError:
[ 213s] pass
[ 213s] # Add the value to the list
[ 213s] filling_values[key] = val
[ 213s] # We have a sequence : update on a one-to-one basis
[ 213s] elif isinstance(user_filling_values, (list, tuple)):
[ 213s] n = len(user_filling_values)
[ 213s] if (n <= nbcols):
[ 213s] filling_values[:n] = user_filling_values
[ 213s] else:
[ 213s] filling_values = user_filling_values[:nbcols]
[ 213s] # We have something else : use it for all entries
[ 213s] else:
[ 213s] filling_values = [user_filling_values] * nbcols
[ 213s]
[ 213s] # Initialize the converters ................................
[ 213s] if dtype is None:
[ 213s] # Note: we can't use a [...]*nbcols, as we would have 3 times the same
[ 213s] # ... converter, instead of 3 different converters.
[ 213s] converters = [StringConverter(None, missing_values=miss, default=fill)
[ 213s] for (miss, fill) in zip(missing_values, filling_values)]
[ 213s] else:
[ 213s] dtype_flat = flatten_dtype(dtype, flatten_base=True)
[ 213s] # Initialize the converters
[ 213s] if len(dtype_flat) > 1:
[ 213s] # Flexible type : get a converter from each dtype
[ 213s] zipit = zip(dtype_flat, missing_values, filling_values)
[ 213s] converters = [StringConverter(dt, locked=True,
[ 213s] missing_values=miss, default=fill)
[ 213s] for (dt, miss, fill) in zipit]
[ 213s] else:
[ 213s] # Set to a default converter (but w/ different missing values)
[ 213s] zipit = zip(missing_values, filling_values)
[ 213s] converters = [StringConverter(dtype, locked=True,
[ 213s] missing_values=miss, default=fill)
[ 213s] for (miss, fill) in zipit]
[ 213s] # Update the converters to use the user-defined ones
[ 213s] uc_update = []
[ 213s] for (j, conv) in user_converters.items():
[ 213s] # If the converter is specified by column names, use the index instead
[ 213s] if _is_string_like(j):
[ 213s] try:
[ 213s] j = names.index(j)
[ 213s] i = j
[ 213s] except ValueError:
[ 213s] continue
[ 213s] elif usecols:
[ 213s] try:
[ 213s] i = usecols.index(j)
[ 213s] except ValueError:
[ 213s] # Unused converter specified
[ 213s] continue
[ 213s] else:
[ 213s] i = j
[ 213s] # Find the value to test - first_line is not filtered by usecols:
[ 213s] if len(first_line):
[ 213s] testing_value = first_values[j]
[ 213s] else:
[ 213s] testing_value = None
[ 213s] if conv is bytes:
[ 213s] user_conv = asbytes
[ 213s] elif byte_converters:
[ 213s] # converters may use decode to workaround numpy's old behaviour,
[ 213s] # so encode the string again before passing to the user converter
[ 213s] def tobytes_first(x, conv):
[ 213s] if type(x) is bytes:
[ 213s] return conv(x)
[ 213s] return conv(x.encode("latin1"))
[ 213s] user_conv = functools.partial(tobytes_first, conv=conv)
[ 213s] else:
[ 213s] user_conv = conv
[ 213s] converters[i].update(user_conv, locked=True,
[ 213s] testing_value=testing_value,
[ 213s] default=filling_values[i],
[ 213s] missing_values=missing_values[i],)
[ 213s] uc_update.append((i, user_conv))
[ 213s] # Make sure we have the corrected keys in user_converters...
[ 213s] user_converters.update(uc_update)
[ 213s]
[ 213s] # Fixme: possible error as following variable never used.
[ 213s] # miss_chars = [_.missing_values for _ in converters]
[ 213s]
[ 213s] # Initialize the output lists ...
[ 213s] # ... rows
[ 213s] rows = []
[ 213s] append_to_rows = rows.append
[ 213s] # ... masks
[ 213s] if usemask:
[ 213s] masks = []
[ 213s] append_to_masks = masks.append
[ 213s] # ... invalid
[ 213s] invalid = []
[ 213s] append_to_invalid = invalid.append
[ 213s]
[ 213s] # Parse each line
[ 213s] for (i, line) in enumerate(itertools.chain([first_line, ], fhd)):
[ 213s] values = split_line(line)
[ 213s] nbvalues = len(values)
[ 213s] # Skip an empty line
[ 213s] if nbvalues == 0:
[ 213s] continue
[ 213s] if usecols:
[ 213s] # Select only the columns we need
[ 213s] try:
[ 213s] values = [values[_] for _ in usecols]
[ 213s] except IndexError:
[ 213s] append_to_invalid((i + skip_header + 1, nbvalues))
[ 213s] continue
[ 213s] elif nbvalues != nbcols:
[ 213s] append_to_invalid((i + skip_header + 1, nbvalues))
[ 213s] continue
[ 213s] # Store the values
[ 213s] append_to_rows(tuple(values))
[ 213s] if usemask:
[ 213s] append_to_masks(tuple([v.strip() in m
[ 213s] for (v, m) in zip(values,
[ 213s] missing_values)]))
[ 213s] if len(rows) == max_rows:
[ 213s] break
[ 213s]
[ 213s] # Upgrade the converters (if needed)
[ 213s] if dtype is None:
[ 213s] for (i, converter) in enumerate(converters):
[ 213s] current_column = [itemgetter(i)(_m) for _m in rows]
[ 213s] try:
[ 213s] converter.iterupgrade(current_column)
[ 213s] except ConverterLockError:
[ 213s] errmsg = "Converter #%i is locked and cannot be upgraded: " % i
[ 213s] current_column = map(itemgetter(i), rows)
[ 213s] for (j, value) in enumerate(current_column):
[ 213s] try:
[ 213s] converter.upgrade(value)
[ 213s] except (ConverterError, ValueError):
[ 213s] errmsg += "(occurred line #%i for value '%s')"
[ 213s] errmsg %= (j + 1 + skip_header, value)
[ 213s] raise ConverterError(errmsg)
[ 213s]
[ 213s] # Check that we don't have invalid values
[ 213s] nbinvalid = len(invalid)
[ 213s] if nbinvalid > 0:
[ 213s] nbrows = len(rows) + nbinvalid - skip_footer
[ 213s] # Construct the error message
[ 213s] template = " Line #%%i (got %%i columns instead of %i)" % nbcols
[ 213s] if skip_footer > 0:
[ 213s] nbinvalid_skipped = len([_ for _ in invalid
[ 213s] if _[0] > nbrows + skip_header])
[ 213s] invalid = invalid[:nbinvalid - nbinvalid_skipped]
[ 213s] skip_footer -= nbinvalid_skipped
[ 213s] #
[ 213s] # nbrows -= skip_footer
[ 213s] # errmsg = [template % (i, nb)
[ 213s] # for (i, nb) in invalid if i < nbrows]
[ 213s] # else:
[ 213s] errmsg = [template % (i, nb)
[ 213s] for (i, nb) in invalid]
[ 213s] if len(errmsg):
[ 213s] errmsg.insert(0, "Some errors were detected !")
[ 213s] errmsg = "\n".join(errmsg)
[ 213s] # Raise an exception ?
[ 213s] if invalid_raise:
[ 213s] raise ValueError(errmsg)
[ 213s] # Issue a warning ?
[ 213s] else:
[ 213s] warnings.warn(errmsg, ConversionWarning, stacklevel=2)
[ 213s]
[ 213s] # Strip the last skip_footer data
[ 213s] if skip_footer > 0:
[ 213s] rows = rows[:-skip_footer]
[ 213s] if usemask:
[ 213s] masks = masks[:-skip_footer]
[ 213s]
[ 213s] # Convert each value according to the converter:
[ 213s] # We want to modify the list in place to avoid creating a new one...
[ 213s] if loose:
[ 213s] rows = list(
[ 213s] zip(*[[conv._loose_call(_r) for _r in map(itemgetter(i), rows)]
[ 213s] for (i, conv) in enumerate(converters)]))
[ 213s] else:
[ 213s] rows = list(
[ 213s] zip(*[[conv._strict_call(_r) for _r in map(itemgetter(i), rows)]
[ 213s] for (i, conv) in enumerate(converters)]))
[ 213s]
[ 213s] # Reset the dtype
[ 213s] data = rows
[ 213s] if dtype is None:
[ 213s] # Get the dtypes from the types of the converters
[ 213s] column_types = [conv.type for conv in converters]
[ 213s] # Find the columns with strings...
[ 213s] strcolidx = [i for (i, v) in enumerate(column_types)
[ 213s] if v == np.unicode_]
[ 213s]
[ 213s] if byte_converters and strcolidx:
[ 213s] # convert strings back to bytes for backward compatibility
[ 213s] warnings.warn(
[ 213s] "Reading unicode strings without specifying the encoding "
[ 213s] "argument is deprecated. Set the encoding, use None for the "
[ 213s] "system default.",
[ 213s] np.VisibleDeprecationWarning, stacklevel=2)
[ 213s] def encode_unicode_cols(row_tup):
[ 213s] row = list(row_tup)
[ 213s] for i in strcolidx:
[ 213s] row[i] = row[i].encode('latin1')
[ 213s] return tuple(row)
[ 213s]
[ 213s] try:
[ 213s] data = [encode_unicode_cols(r) for r in data]
[ 213s] except UnicodeEncodeError:
[ 213s] pass
[ 213s] else:
[ 213s] for i in strcolidx:
[ 213s] column_types[i] = np.bytes_
[ 213s]
[ 213s] # Update string types to be the right length
[ 213s] sized_column_types = column_types[:]
[ 213s] for i, col_type in enumerate(column_types):
[ 213s] if np.issubdtype(col_type, np.character):
[ 213s] n_chars = max(len(row[i]) for row in data)
[ 213s] sized_column_types[i] = (col_type, n_chars)
[ 213s]
[ 213s] if names is None:
[ 213s] # If the dtype is uniform (before sizing strings)
[ 213s] base = {
[ 213s] c_type
[ 213s] for c, c_type in zip(converters, column_types)
[ 213s] if c._checked}
[ 213s] if len(base) == 1:
[ 213s] uniform_type, = base
[ 213s] (ddtype, mdtype) = (uniform_type, bool)
[ 213s] else:
[ 213s] ddtype = [(defaultfmt % i, dt)
[ 213s] for (i, dt) in enumerate(sized_column_types)]
[ 213s] if usemask:
[ 213s] mdtype = [(defaultfmt % i, bool)
[ 213s] for (i, dt) in enumerate(sized_column_types)]
[ 213s] else:
[ 213s] ddtype = list(zip(names, sized_column_types))
[ 213s] mdtype = list(zip(names, [bool] * len(sized_column_types)))
[ 213s] output = np.array(data, dtype=ddtype)
[ 213s] if usemask:
[ 213s] outputmask = np.array(masks, dtype=mdtype)
[ 213s] else:
[ 213s] # Overwrite the initial dtype names if needed
[ 213s] if names and dtype.names is not None:
[ 213s] dtype.names = names
[ 213s] # Case 1. We have a structured type
[ 213s] if len(dtype_flat) > 1:
[ 213s] # Nested dtype, eg [('a', int), ('b', [('b0', int), ('b1', 'f4')])]
[ 213s] # First, create the array using a flattened dtype:
[ 213s] # [('a', int), ('b1', int), ('b2', float)]
[ 213s] # Then, view the array using the specified dtype.
[ 213s] if 'O' in (_.char for _ in dtype_flat):
[ 213s] if has_nested_fields(dtype):
[ 213s] raise NotImplementedError(
[ 213s] "Nested fields involving objects are not supported...")
[ 213s] else:
[ 213s] output = np.array(data, dtype=dtype)
[ 213s] else:
[ 213s] rows = np.array(data, dtype=[('', _) for _ in dtype_flat])
[ 213s] output = rows.view(dtype)
[ 213s] # Now, process the rowmasks the same way
[ 213s] if usemask:
[ 213s] rowmasks = np.array(
[ 213s] masks, dtype=np.dtype([('', bool) for t in dtype_flat]))
[ 213s] # Construct the new dtype
[ 213s] mdtype = make_mask_descr(dtype)
[ 213s] outputmask = rowmasks.view(mdtype)
[ 213s] # Case #2. We have a basic dtype
[ 213s] else:
[ 213s] # We used some user-defined converters
[ 213s] if user_converters:
[ 213s] ishomogeneous = True
[ 213s] descr = []
[ 213s] for i, ttype in enumerate([conv.type for conv in converters]):
[ 213s] # Keep the dtype of the current converter
[ 213s] if i in user_converters:
[ 213s] ishomogeneous &= (ttype == dtype.type)
[ 213s] if np.issubdtype(ttype, np.character):
[ 213s] ttype = (ttype, max(len(row[i]) for row in data))
[ 213s] descr.append(('', ttype))
[ 213s] else:
[ 213s] descr.append(('', dtype))
[ 213s] # So we changed the dtype ?
[ 213s] if not ishomogeneous:
[ 213s] # We have more than one field
[ 213s] if len(descr) > 1:
[ 213s] dtype = np.dtype(descr)
[ 213s] # We have only one field: drop the name if not needed.
[ 213s] else:
[ 213s] dtype = np.dtype(ttype)
[ 213s] #
[ 213s] output = np.array(data, dtype)
[ 213s] if usemask:
[ 213s] if dtype.names is not None:
[ 213s] mdtype = [(_, bool) for _ in dtype.names]
[ 213s] else:
[ 213s] mdtype = bool
[ 213s] outputmask = np.array(masks, dtype=mdtype)
[ 213s] # Try to take care of the missing data we missed
[ 213s] names = output.dtype.names
[ 213s] if usemask and names:
[ 213s] for (name, conv) in zip(names, converters):
[ 213s] missing_values = [conv(_) for _ in conv.missing_values
[ 213s] if _ != '']
[ 213s] for mval in missing_values:
[ 213s] > outputmask[name] |= (output[name] == mval)
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] MaskedArray = <class 'numpy.ma.core.MaskedArray'>
[ 213s] append_to_invalid = <built-in method append of list object at 0xef52e948>
[ 213s] append_to_masks = <built-in method append of list object at 0xef52ed68>
[ 213s] append_to_rows = <built-in method append of list object at 0xeef1c308>
[ 213s] autostrip = False
[ 213s] byte_converters = True
[ 213s] case_sensitive = True
[ 213s] comments = '#'
[ 213s] conv = <numpy.lib._iotools.StringConverter object at 0xef3762e0>
[ 213s] converters = [<numpy.lib._iotools.StringConverter object at 0xef3762e0>, <numpy.lib._iotools.StringConverter object at 0xef3762c8>]
[ 213s] data = [(0.0, 1.0), (2.0, nan)]
[ 213s] defaultfmt = 'f%i'
[ 213s] deletechars = " !#$%&'()*+,-./:;<=>?@[\\]^{|}~"
[ 213s] delimiter = ','
[ 213s] dtype = dtype([('A', '<f8'), ('B', '<f8')])
[ 213s] dtype_flat = [dtype('float64'), dtype('float64')]
[ 213s] encoding = None
[ 213s] entry = ['', 'N/A']
[ 213s] excludelist = None
[ 213s] fhd = <numpy.lib.tests.test_io.TextIO object at 0xef2c04d8>
[ 213s] fid = <numpy.lib.tests.test_io.TextIO object at 0xef2c04d8>
[ 213s] fid_ctx = <numpy.compat.py3k.contextlib_nullcontext object at 0xef376298>
[ 213s] filling_values = [None, None]
[ 213s] first_line = ''
[ 213s] first_values = ['A', 'B']
[ 213s] fname = <numpy.lib.tests.test_io.TextIO object at 0xef2c04d8>
[ 213s] fval = 'A'
[ 213s] i = 2
[ 213s] invalid = []
[ 213s] invalid_raise = True
[ 213s] line = b'2,N/A'
[ 213s] loose = True
[ 213s] make_mask_descr = <function make_mask_descr at 0xdcd3e2b0>
[ 213s] masks = [(False, False), (False, True)]
[ 213s] max_rows = None
[ 213s] mdtype = dtype([('A', '?'), ('B', '?')])
[ 213s] missing_values = [nan]
[ 213s] mval = nan
[ 213s] n = 0
[ 213s] name = 'A'
[ 213s] names = ('A', 'B')
[ 213s] nbcols = 2
[ 213s] nbinvalid = 0
[ 213s] nbvalues = 2
[ 213s] output = array([(0., 1.), (2., nan)], dtype=[('A', '<f8'), ('B', '<f8')])
[ 213s] outputmask = array([(False, False), (False, True)], dtype=[('A', '?'), ('B', '?')])
[ 213s] replace_space = '_'
[ 213s] rowmasks = array([(False, False), (False, True)], dtype=[('f0', '?'), ('f1', '?')])
[ 213s] rows = array([(0., 1.), (2., nan)], dtype=[('f0', '<f8'), ('f1', '<f8')])
[ 213s] skip_footer = 0
[ 213s] skip_header = 0
[ 213s] split_line = <numpy.lib._iotools.LineSplitter object at 0xef3764d8>
[ 213s] uc_update = []
[ 213s] unpack = None
[ 213s] usecols = None
[ 213s] usemask = True
[ 213s] user_converters = {}
[ 213s] user_filling_values = []
[ 213s] user_missing_values = 'N/A'
[ 213s] user_value = ['N/A']
[ 213s] validate_names = <numpy.lib._iotools.NameValidator object at 0xef3760d0>
[ 213s] values = ['2', 'N/A']
[ 213s] zipit = <zip object at 0xef52e108>
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/npyio.py:2247: DeprecationWarning
[ 213s] ______________________ TestIO.test_roundtrip_dump_pathlib ______________________
[ 213s] [gw13] linux -- Python 3.8.2 /usr/bin/python3
[ 213s] RuntimeWarning: invalid value encountered in equal
[ 213s]
[ 213s] The above exception was the direct cause of the following exception:
[ 213s]
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf23ba1a8>
[ 213s]
[ 213s] @pytest.mark.skipif(pathlib is None, reason="pathlib not found")
[ 213s] def test_roundtrip_dump_pathlib(self):
[ 213s] p = pathlib.Path(self.filename)
[ 213s] self.x.dump(p)
[ 213s] y = np.load(p, allow_pickle=True)
[ 213s] > assert_array_equal(y, self.x)
[ 213s]
[ 213s] p = PosixPath('/tmp/tmpzuxnfk6d/tmpjq_aj4j7')
[ 213s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf23ba1a8>
[ 213s] y = array([[[0.84602469+0.23722471j, nan+0.j ,
[ 213s] 0.90255503+0.80987834j],
[ 213s] [0.22599553+0.95456... 0.9384556 +0.69480742j],
[ 213s] [0.93864246+0.76197389j, 0.74504455+0.42520918j,
[ 213s] 0.91073504+0.13889344j]]])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4703:
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 213s] x_id = func(x)
[ 213s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 213s]
[ 213s] xy = array([[[0.84602469+0.23722471j, nan+0.j ,
[ 213s] 0.90255503+0.80987834j],
[ 213s] [0.22599553+0.95456... 0.9384556 +0.69480742j],
[ 213s] [0.93864246+0.76197389j, 0.74504455+0.42520918j,
[ 213s] 0.91073504+0.13889344j]]])
[ 213s]
[ 213s] > func=lambda xy: xy == +inf,
[ 213s] hasval='+inf')
[ 213s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 213s]
[ 213s] inf = inf
[ 213s] xy = array([[[0.84602469+0.23722471j, nan+0.j ,
[ 213s] 0.90255503+0.80987834j],
[ 213s] [0.22599553+0.95456... 0.9384556 +0.69480742j],
[ 213s] [0.93864246+0.76197389j, 0.74504455+0.42520918j,
[ 213s] 0.91073504+0.13889344j]]])
[ 213s]
[ 213s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] __________________ TestNanFunctions_MeanVarStd.test_mutation ___________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_MeanVarStd object at 0xf27ea6a0>
[ 214s]
[ 214s] def test_mutation(self):
[ 214s] # Check that passed array is not modified.
[ 214s] ndat = _ndat.copy()
[ 214s] for f in self.nanfuncs:
[ 214s] f(ndat)
[ 214s] > assert_equal(ndat, _ndat)
[ 214s]
[ 214s] f = <function nanmean at 0xddf56bf8>
[ 214s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_MeanVarStd object at 0xf27ea6a0>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:317:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _____________________ TestFromTxt.test_user_missing_values _____________________
[ 214s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xeefe2a78>
[ 214s]
[ 214s] def test_user_missing_values(self):
[ 214s] data = "A, B, C\n0, 0., 0j\n1, N/A, 1j\n-9, 2.2, N/A\n3, -99, 3j"
[ 214s] basekwargs = dict(dtype=None, delimiter=",", names=True,)
[ 214s] mdtype = [('A', int), ('B', float), ('C', complex)]
[ 214s] #
[ 214s] test = np.genfromtxt(TextIO(data), missing_values="N/A",
[ 214s] **basekwargs)
[ 214s] control = ma.array([(0, 0.0, 0j), (1, -999, 1j),
[ 214s] (-9, 2.2, -999j), (3, -99, 3j)],
[ 214s] mask=[(0, 0, 0), (0, 1, 0), (0, 0, 1), (0, 0, 0)],
[ 214s] dtype=mdtype)
[ 214s] assert_equal(test, control)
[ 214s] #
[ 214s] basekwargs['dtype'] = mdtype
[ 214s] > test = np.genfromtxt(TextIO(data),
[ 214s] missing_values={0: -9, 1: -99, 2: -999j}, usemask=True, **basekwargs)
[ 214s]
[ 214s] basekwargs = {'delimiter': ',', 'dtype': [('A', <class 'int'>), ('B', <class 'float'>), ('C', <class 'complex'>)], 'names': True}
[ 214s] control = masked_array(data=[(0, 0.0, 0j), (1, --, 1j), (-9, 2.2, --),
[ 214s] (3, -99.0, 3j)],
[ 214s] mask=[(F...False)],
[ 214s] fill_value=(999999, 1.e+20, 1.e+20+0.j),
[ 214s] dtype=[('A', '<i4'), ('B', '<f8'), ('C', '<c16')])
[ 214s] data = 'A, B, C\n0, 0., 0j\n1, N/A, 1j\n-9, 2.2, N/A\n3, -99, 3j'
[ 214s] mdtype = [('A', <class 'int'>), ('B', <class 'float'>), ('C', <class 'complex'>)]
[ 214s] self = <numpy.lib.tests.test_io.TestFromTxt object at 0xeefe2a78>
[ 214s] test = array([( 0, 0. , 0.+0.j), ( 1, nan, 0.+1.j), (-9, 2.2, nan+0.j),
[ 214s] ( 3, -99. , 0.+3.j)],
[ 214s] dtype=[('A', '<i4'), ('B', '<f8'), ('C', '<c16')])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_io.py:1741:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] fname = <numpy.lib.tests.test_io.TextIO object at 0xef530be0>
[ 214s] dtype = dtype([('A', '<i4'), ('B', '<f8'), ('C', '<c16')]), comments = '#'
[ 214s] delimiter = ',', skip_header = 0, skip_footer = 0
[ 214s] converters = [<numpy.lib._iotools.StringConverter object at 0xef20b118>, <numpy.lib._iotools.StringConverter object at 0xef20b460>, <numpy.lib._iotools.StringConverter object at 0xef20b4a8>]
[ 214s] missing_values = [-99.0], filling_values = [None, None, None], usecols = None
[ 214s] names = ('A', 'B', 'C'), excludelist = None
[ 214s] deletechars = " !#$%&'()*+,-./:;<=>?@[\\]^{|}~", replace_space = '_'
[ 214s] autostrip = False, case_sensitive = True, defaultfmt = 'f%i', unpack = None
[ 214s] usemask = True, loose = True, invalid_raise = True, max_rows = None
[ 214s] encoding = None
[ 214s]
[ 214s] @set_module('numpy')
[ 214s] def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
[ 214s] skip_header=0, skip_footer=0, converters=None,
[ 214s] missing_values=None, filling_values=None, usecols=None,
[ 214s] names=None, excludelist=None,
[ 214s] deletechars=''.join(sorted(NameValidator.defaultdeletechars)),
[ 214s] replace_space='_', autostrip=False, case_sensitive=True,
[ 214s] defaultfmt="f%i", unpack=None, usemask=False, loose=True,
[ 214s] invalid_raise=True, max_rows=None, encoding='bytes'):
[ 214s] """
[ 214s] Load data from a text file, with missing values handled as specified.
[ 214s]
[ 214s] Each line past the first `skip_header` lines is split at the `delimiter`
[ 214s] character, and characters following the `comments` character are discarded.
[ 214s]
[ 214s] Parameters
[ 214s] ----------
[ 214s] fname : file, str, pathlib.Path, list of str, generator
[ 214s] File, filename, list, or generator to read. If the filename
[ 214s] extension is `.gz` or `.bz2`, the file is first decompressed. Note
[ 214s] that generators must return byte strings. The strings
[ 214s] in a list or produced by a generator are treated as lines.
[ 214s] dtype : dtype, optional
[ 214s] Data type of the resulting array.
[ 214s] If None, the dtypes will be determined by the contents of each
[ 214s] column, individually.
[ 214s] comments : str, optional
[ 214s] The character used to indicate the start of a comment.
[ 214s] All the characters occurring on a line after a comment are discarded
[ 214s] delimiter : str, int, or sequence, optional
[ 214s] The string used to separate values. By default, any consecutive
[ 214s] whitespaces act as delimiter. An integer or sequence of integers
[ 214s] can also be provided as width(s) of each field.
[ 214s] skiprows : int, optional
[ 214s] `skiprows` was removed in numpy 1.10. Please use `skip_header` instead.
[ 214s] skip_header : int, optional
[ 214s] The number of lines to skip at the beginning of the file.
[ 214s] skip_footer : int, optional
[ 214s] The number of lines to skip at the end of the file.
[ 214s] converters : variable, optional
[ 214s] The set of functions that convert the data of a column to a value.
[ 214s] The converters can also be used to provide a default value
[ 214s] for missing data: ``converters = {3: lambda s: float(s or 0)}``.
[ 214s] missing : variable, optional
[ 214s] `missing` was removed in numpy 1.10. Please use `missing_values`
[ 214s] instead.
[ 214s] missing_values : variable, optional
[ 214s] The set of strings corresponding to missing data.
[ 214s] filling_values : variable, optional
[ 214s] The set of values to be used as default when the data are missing.
[ 214s] usecols : sequence, optional
[ 214s] Which columns to read, with 0 being the first. For example,
[ 214s] ``usecols = (1, 4, 5)`` will extract the 2nd, 5th and 6th columns.
[ 214s] names : {None, True, str, sequence}, optional
[ 214s] If `names` is True, the field names are read from the first line after
[ 214s] the first `skip_header` lines. This line can optionally be proceeded
[ 214s] by a comment delimiter. If `names` is a sequence or a single-string of
[ 214s] comma-separated names, the names will be used to define the field names
[ 214s] in a structured dtype. If `names` is None, the names of the dtype
[ 214s] fields will be used, if any.
[ 214s] excludelist : sequence, optional
[ 214s] A list of names to exclude. This list is appended to the default list
[ 214s] ['return','file','print']. Excluded names are appended an underscore:
[ 214s] for example, `file` would become `file_`.
[ 214s] deletechars : str, optional
[ 214s] A string combining invalid characters that must be deleted from the
[ 214s] names.
[ 214s] defaultfmt : str, optional
[ 214s] A format used to define default field names, such as "f%i" or "f_%02i".
[ 214s] autostrip : bool, optional
[ 214s] Whether to automatically strip white spaces from the variables.
[ 214s] replace_space : char, optional
[ 214s] Character(s) used in replacement of white spaces in the variables
[ 214s] names. By default, use a '_'.
[ 214s] case_sensitive : {True, False, 'upper', 'lower'}, optional
[ 214s] If True, field names are case sensitive.
[ 214s] If False or 'upper', field names are converted to upper case.
[ 214s] If 'lower', field names are converted to lower case.
[ 214s] unpack : bool, optional
[ 214s] If True, the returned array is transposed, so that arguments may be
[ 214s] unpacked using ``x, y, z = loadtxt(...)``
[ 214s] usemask : bool, optional
[ 214s] If True, return a masked array.
[ 214s] If False, return a regular array.
[ 214s] loose : bool, optional
[ 214s] If True, do not raise errors for invalid values.
[ 214s] invalid_raise : bool, optional
[ 214s] If True, an exception is raised if an inconsistency is detected in the
[ 214s] number of columns.
[ 214s] If False, a warning is emitted and the offending lines are skipped.
[ 214s] max_rows : int, optional
[ 214s] The maximum number of rows to read. Must not be used with skip_footer
[ 214s] at the same time. If given, the value must be at least 1. Default is
[ 214s] to read the entire file.
[ 214s]
[ 214s] .. versionadded:: 1.10.0
[ 214s] encoding : str, optional
[ 214s] Encoding used to decode the inputfile. Does not apply when `fname` is
[ 214s] a file object. The special value 'bytes' enables backward compatibility
[ 214s] workarounds that ensure that you receive byte arrays when possible
[ 214s] and passes latin1 encoded strings to converters. Override this value to
[ 214s] receive unicode arrays and pass strings as input to converters. If set
[ 214s] to None the system default is used. The default value is 'bytes'.
[ 214s]
[ 214s] .. versionadded:: 1.14.0
[ 214s]
[ 214s] Returns
[ 214s] -------
[ 214s] out : ndarray
[ 214s] Data read from the text file. If `usemask` is True, this is a
[ 214s] masked array.
[ 214s]
[ 214s] See Also
[ 214s] --------
[ 214s] numpy.loadtxt : equivalent function when no data is missing.
[ 214s]
[ 214s] Notes
[ 214s] -----
[ 214s] * When spaces are used as delimiters, or when no delimiter has been given
[ 214s] as input, there should not be any missing data between two fields.
[ 214s] * When the variables are named (either by a flexible dtype or with `names`,
[ 214s] there must not be any header in the file (else a ValueError
[ 214s] exception is raised).
[ 214s] * Individual values are not stripped of spaces by default.
[ 214s] When using a custom converter, make sure the function does remove spaces.
[ 214s]
[ 214s] References
[ 214s] ----------
[ 214s] .. [1] NumPy User Guide, section `I/O with NumPy
[ 214s] <https://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html>`_.
[ 214s]
[ 214s] Examples
[ 214s] ---------
[ 214s] >>> from io import StringIO
[ 214s] >>> import numpy as np
[ 214s]
[ 214s] Comma delimited file with mixed dtype
[ 214s]
[ 214s] >>> s = StringIO(u"1,1.3,abcde")
[ 214s] >>> data = np.genfromtxt(s, dtype=[('myint','i8'),('myfloat','f8'),
[ 214s] ... ('mystring','S5')], delimiter=",")
[ 214s] >>> data
[ 214s] array((1, 1.3, b'abcde'),
[ 214s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 214s]
[ 214s] Using dtype = None
[ 214s]
[ 214s] >>> _ = s.seek(0) # needed for StringIO example only
[ 214s] >>> data = np.genfromtxt(s, dtype=None,
[ 214s] ... names = ['myint','myfloat','mystring'], delimiter=",")
[ 214s] >>> data
[ 214s] array((1, 1.3, b'abcde'),
[ 214s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 214s]
[ 214s] Specifying dtype and names
[ 214s]
[ 214s] >>> _ = s.seek(0)
[ 214s] >>> data = np.genfromtxt(s, dtype="i8,f8,S5",
[ 214s] ... names=['myint','myfloat','mystring'], delimiter=",")
[ 214s] >>> data
[ 214s] array((1, 1.3, b'abcde'),
[ 214s] dtype=[('myint', '<i8'), ('myfloat', '<f8'), ('mystring', 'S5')])
[ 214s]
[ 214s] An example with fixed-width columns
[ 214s]
[ 214s] >>> s = StringIO(u"11.3abcde")
[ 214s] >>> data = np.genfromtxt(s, dtype=None, names=['intvar','fltvar','strvar'],
[ 214s] ... delimiter=[1,3,5])
[ 214s] >>> data
[ 214s] array((1, 1.3, b'abcde'),
[ 214s] dtype=[('intvar', '<i8'), ('fltvar', '<f8'), ('strvar', 'S5')])
[ 214s]
[ 214s] An example to show comments
[ 214s]
[ 214s] >>> f = StringIO('''
[ 214s] ... text,# of chars
[ 214s] ... hello world,11
[ 214s] ... numpy,5''')
[ 214s] >>> np.genfromtxt(f, dtype='S12,S12', delimiter=',')
[ 214s] array([(b'text', b''), (b'hello world', b'11'), (b'numpy', b'5')],
[ 214s] dtype=[('f0', 'S12'), ('f1', 'S12')])
[ 214s]
[ 214s] """
[ 214s] if max_rows is not None:
[ 214s] if skip_footer:
[ 214s] raise ValueError(
[ 214s] "The keywords 'skip_footer' and 'max_rows' can not be "
[ 214s] "specified at the same time.")
[ 214s] if max_rows < 1:
[ 214s] raise ValueError("'max_rows' must be at least 1.")
[ 214s]
[ 214s] if usemask:
[ 214s] from numpy.ma import MaskedArray, make_mask_descr
[ 214s] # Check the input dictionary of converters
[ 214s] user_converters = converters or {}
[ 214s] if not isinstance(user_converters, dict):
[ 214s] raise TypeError(
[ 214s] "The input argument 'converter' should be a valid dictionary "
[ 214s] "(got '%s' instead)" % type(user_converters))
[ 214s]
[ 214s] if encoding == 'bytes':
[ 214s] encoding = None
[ 214s] byte_converters = True
[ 214s] else:
[ 214s] byte_converters = False
[ 214s]
[ 214s] # Initialize the filehandle, the LineSplitter and the NameValidator
[ 214s] try:
[ 214s] if isinstance(fname, os_PathLike):
[ 214s] fname = os_fspath(fname)
[ 214s] if isinstance(fname, basestring):
[ 214s] fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)
[ 214s] fid_ctx = contextlib.closing(fid)
[ 214s] else:
[ 214s] fid = fname
[ 214s] fid_ctx = contextlib_nullcontext(fid)
[ 214s] fhd = iter(fid)
[ 214s] except TypeError:
[ 214s] raise TypeError(
[ 214s] "fname must be a string, filehandle, list of strings, "
[ 214s] "or generator. Got %s instead." % type(fname))
[ 214s]
[ 214s] with fid_ctx:
[ 214s] split_line = LineSplitter(delimiter=delimiter, comments=comments,
[ 214s] autostrip=autostrip, encoding=encoding)
[ 214s] validate_names = NameValidator(excludelist=excludelist,
[ 214s] deletechars=deletechars,
[ 214s] case_sensitive=case_sensitive,
[ 214s] replace_space=replace_space)
[ 214s]
[ 214s] # Skip the first `skip_header` rows
[ 214s] try:
[ 214s] for i in range(skip_header):
[ 214s] next(fhd)
[ 214s]
[ 214s] # Keep on until we find the first valid values
[ 214s] first_values = None
[ 214s]
[ 214s] while not first_values:
[ 214s] first_line = _decode_line(next(fhd), encoding)
[ 214s] if (names is True) and (comments is not None):
[ 214s] if comments in first_line:
[ 214s] first_line = (
[ 214s] ''.join(first_line.split(comments)[1:]))
[ 214s] first_values = split_line(first_line)
[ 214s] except StopIteration:
[ 214s] # return an empty array if the datafile is empty
[ 214s] first_line = ''
[ 214s] first_values = []
[ 214s] warnings.warn('genfromtxt: Empty input file: "%s"' % fname, stacklevel=2)
[ 214s]
[ 214s] # Should we take the first values as names ?
[ 214s] if names is True:
[ 214s] fval = first_values[0].strip()
[ 214s] if comments is not None:
[ 214s] if fval in comments:
[ 214s] del first_values[0]
[ 214s]
[ 214s] # Check the columns to use: make sure `usecols` is a list
[ 214s] if usecols is not None:
[ 214s] try:
[ 214s] usecols = [_.strip() for _ in usecols.split(",")]
[ 214s] except AttributeError:
[ 214s] try:
[ 214s] usecols = list(usecols)
[ 214s] except TypeError:
[ 214s] usecols = [usecols, ]
[ 214s] nbcols = len(usecols or first_values)
[ 214s]
[ 214s] # Check the names and overwrite the dtype.names if needed
[ 214s] if names is True:
[ 214s] names = validate_names([str(_.strip()) for _ in first_values])
[ 214s] first_line = ''
[ 214s] elif _is_string_like(names):
[ 214s] names = validate_names([_.strip() for _ in names.split(',')])
[ 214s] elif names:
[ 214s] names = validate_names(names)
[ 214s] # Get the dtype
[ 214s] if dtype is not None:
[ 214s] dtype = easy_dtype(dtype, defaultfmt=defaultfmt, names=names,
[ 214s] excludelist=excludelist,
[ 214s] deletechars=deletechars,
[ 214s] case_sensitive=case_sensitive,
[ 214s] replace_space=replace_space)
[ 214s] # Make sure the names is a list (for 2.5)
[ 214s] if names is not None:
[ 214s] names = list(names)
[ 214s]
[ 214s] if usecols:
[ 214s] for (i, current) in enumerate(usecols):
[ 214s] # if usecols is a list of names, convert to a list of indices
[ 214s] if _is_string_like(current):
[ 214s] usecols[i] = names.index(current)
[ 214s] elif current < 0:
[ 214s] usecols[i] = current + len(first_values)
[ 214s] # If the dtype is not None, make sure we update it
[ 214s] if (dtype is not None) and (len(dtype) > nbcols):
[ 214s] descr = dtype.descr
[ 214s] dtype = np.dtype([descr[_] for _ in usecols])
[ 214s] names = list(dtype.names)
[ 214s] # If `names` is not None, update the names
[ 214s] elif (names is not None) and (len(names) > nbcols):
[ 214s] names = [names[_] for _ in usecols]
[ 214s] elif (names is not None) and (dtype is not None):
[ 214s] names = list(dtype.names)
[ 214s]
[ 214s] # Process the missing values ...............................
[ 214s] # Rename missing_values for convenience
[ 214s] user_missing_values = missing_values or ()
[ 214s] if isinstance(user_missing_values, bytes):
[ 214s] user_missing_values = user_missing_values.decode('latin1')
[ 214s]
[ 214s] # Define the list of missing_values (one column: one list)
[ 214s] missing_values = [list(['']) for _ in range(nbcols)]
[ 214s]
[ 214s] # We have a dictionary: process it field by field
[ 214s] if isinstance(user_missing_values, dict):
[ 214s] # Loop on the items
[ 214s] for (key, val) in user_missing_values.items():
[ 214s] # Is the key a string ?
[ 214s] if _is_string_like(key):
[ 214s] try:
[ 214s] # Transform it into an integer
[ 214s] key = names.index(key)
[ 214s] except ValueError:
[ 214s] # We couldn't find it: the name must have been dropped
[ 214s] continue
[ 214s] # Redefine the key as needed if it's a column number
[ 214s] if usecols:
[ 214s] try:
[ 214s] key = usecols.index(key)
[ 214s] except ValueError:
[ 214s] pass
[ 214s] # Transform the value as a list of string
[ 214s] if isinstance(val, (list, tuple)):
[ 214s] val = [str(_) for _ in val]
[ 214s] else:
[ 214s] val = [str(val), ]
[ 214s] # Add the value(s) to the current list of missing
[ 214s] if key is None:
[ 214s] # None acts as default
[ 214s] for miss in missing_values:
[ 214s] miss.extend(val)
[ 214s] else:
[ 214s] missing_values[key].extend(val)
[ 214s] # We have a sequence : each item matches a column
[ 214s] elif isinstance(user_missing_values, (list, tuple)):
[ 214s] for (value, entry) in zip(user_missing_values, missing_values):
[ 214s] value = str(value)
[ 214s] if value not in entry:
[ 214s] entry.append(value)
[ 214s] # We have a string : apply it to all entries
[ 214s] elif isinstance(user_missing_values, basestring):
[ 214s] user_value = user_missing_values.split(",")
[ 214s] for entry in missing_values:
[ 214s] entry.extend(user_value)
[ 214s] # We have something else: apply it to all entries
[ 214s] else:
[ 214s] for entry in missing_values:
[ 214s] entry.extend([str(user_missing_values)])
[ 214s]
[ 214s] # Process the filling_values ...............................
[ 214s] # Rename the input for convenience
[ 214s] user_filling_values = filling_values
[ 214s] if user_filling_values is None:
[ 214s] user_filling_values = []
[ 214s] # Define the default
[ 214s] filling_values = [None] * nbcols
[ 214s] # We have a dictionary : update each entry individually
[ 214s] if isinstance(user_filling_values, dict):
[ 214s] for (key, val) in user_filling_values.items():
[ 214s] if _is_string_like(key):
[ 214s] try:
[ 214s] # Transform it into an integer
[ 214s] key = names.index(key)
[ 214s] except ValueError:
[ 214s] # We couldn't find it: the name must have been dropped,
[ 214s] continue
[ 214s] # Redefine the key if it's a column number and usecols is defined
[ 214s] if usecols:
[ 214s] try:
[ 214s] key = usecols.index(key)
[ 214s] except ValueError:
[ 214s] pass
[ 214s] # Add the value to the list
[ 214s] filling_values[key] = val
[ 214s] # We have a sequence : update on a one-to-one basis
[ 214s] elif isinstance(user_filling_values, (list, tuple)):
[ 214s] n = len(user_filling_values)
[ 214s] if (n <= nbcols):
[ 214s] filling_values[:n] = user_filling_values
[ 214s] else:
[ 214s] filling_values = user_filling_values[:nbcols]
[ 214s] # We have something else : use it for all entries
[ 214s] else:
[ 214s] filling_values = [user_filling_values] * nbcols
[ 214s]
[ 214s] # Initialize the converters ................................
[ 214s] if dtype is None:
[ 214s] # Note: we can't use a [...]*nbcols, as we would have 3 times the same
[ 214s] # ... converter, instead of 3 different converters.
[ 214s] converters = [StringConverter(None, missing_values=miss, default=fill)
[ 214s] for (miss, fill) in zip(missing_values, filling_values)]
[ 214s] else:
[ 214s] dtype_flat = flatten_dtype(dtype, flatten_base=True)
[ 214s] # Initialize the converters
[ 214s] if len(dtype_flat) > 1:
[ 214s] # Flexible type : get a converter from each dtype
[ 214s] zipit = zip(dtype_flat, missing_values, filling_values)
[ 214s] converters = [StringConverter(dt, locked=True,
[ 214s] missing_values=miss, default=fill)
[ 214s] for (dt, miss, fill) in zipit]
[ 214s] else:
[ 214s] # Set to a default converter (but w/ different missing values)
[ 214s] zipit = zip(missing_values, filling_values)
[ 214s] converters = [StringConverter(dtype, locked=True,
[ 214s] missing_values=miss, default=fill)
[ 214s] for (miss, fill) in zipit]
[ 214s] # Update the converters to use the user-defined ones
[ 214s] uc_update = []
[ 214s] for (j, conv) in user_converters.items():
[ 214s] # If the converter is specified by column names, use the index instead
[ 214s] if _is_string_like(j):
[ 214s] try:
[ 214s] j = names.index(j)
[ 214s] i = j
[ 214s] except ValueError:
[ 214s] continue
[ 214s] elif usecols:
[ 214s] try:
[ 214s] i = usecols.index(j)
[ 214s] except ValueError:
[ 214s] # Unused converter specified
[ 214s] continue
[ 214s] else:
[ 214s] i = j
[ 214s] # Find the value to test - first_line is not filtered by usecols:
[ 214s] if len(first_line):
[ 214s] testing_value = first_values[j]
[ 214s] else:
[ 214s] testing_value = None
[ 214s] if conv is bytes:
[ 214s] user_conv = asbytes
[ 214s] elif byte_converters:
[ 214s] # converters may use decode to workaround numpy's old behaviour,
[ 214s] # so encode the string again before passing to the user converter
[ 214s] def tobytes_first(x, conv):
[ 214s] if type(x) is bytes:
[ 214s] return conv(x)
[ 214s] return conv(x.encode("latin1"))
[ 214s] user_conv = functools.partial(tobytes_first, conv=conv)
[ 214s] else:
[ 214s] user_conv = conv
[ 214s] converters[i].update(user_conv, locked=True,
[ 214s] testing_value=testing_value,
[ 214s] default=filling_values[i],
[ 214s] missing_values=missing_values[i],)
[ 214s] uc_update.append((i, user_conv))
[ 214s] # Make sure we have the corrected keys in user_converters...
[ 214s] user_converters.update(uc_update)
[ 214s]
[ 214s] # Fixme: possible error as following variable never used.
[ 214s] # miss_chars = [_.missing_values for _ in converters]
[ 214s]
[ 214s] # Initialize the output lists ...
[ 214s] # ... rows
[ 214s] rows = []
[ 214s] append_to_rows = rows.append
[ 214s] # ... masks
[ 214s] if usemask:
[ 214s] masks = []
[ 214s] append_to_masks = masks.append
[ 214s] # ... invalid
[ 214s] invalid = []
[ 214s] append_to_invalid = invalid.append
[ 214s]
[ 214s] # Parse each line
[ 214s] for (i, line) in enumerate(itertools.chain([first_line, ], fhd)):
[ 214s] values = split_line(line)
[ 214s] nbvalues = len(values)
[ 214s] # Skip an empty line
[ 214s] if nbvalues == 0:
[ 214s] continue
[ 214s] if usecols:
[ 214s] # Select only the columns we need
[ 214s] try:
[ 214s] values = [values[_] for _ in usecols]
[ 214s] except IndexError:
[ 214s] append_to_invalid((i + skip_header + 1, nbvalues))
[ 214s] continue
[ 214s] elif nbvalues != nbcols:
[ 214s] append_to_invalid((i + skip_header + 1, nbvalues))
[ 214s] continue
[ 214s] # Store the values
[ 214s] append_to_rows(tuple(values))
[ 214s] if usemask:
[ 214s] append_to_masks(tuple([v.strip() in m
[ 214s] for (v, m) in zip(values,
[ 214s] missing_values)]))
[ 214s] if len(rows) == max_rows:
[ 214s] break
[ 214s]
[ 214s] # Upgrade the converters (if needed)
[ 214s] if dtype is None:
[ 214s] for (i, converter) in enumerate(converters):
[ 214s] current_column = [itemgetter(i)(_m) for _m in rows]
[ 214s] try:
[ 214s] converter.iterupgrade(current_column)
[ 214s] except ConverterLockError:
[ 214s] errmsg = "Converter #%i is locked and cannot be upgraded: " % i
[ 214s] current_column = map(itemgetter(i), rows)
[ 214s] for (j, value) in enumerate(current_column):
[ 214s] try:
[ 214s] converter.upgrade(value)
[ 214s] except (ConverterError, ValueError):
[ 214s] errmsg += "(occurred line #%i for value '%s')"
[ 214s] errmsg %= (j + 1 + skip_header, value)
[ 214s] raise ConverterError(errmsg)
[ 214s]
[ 214s] # Check that we don't have invalid values
[ 214s] nbinvalid = len(invalid)
[ 214s] if nbinvalid > 0:
[ 214s] nbrows = len(rows) + nbinvalid - skip_footer
[ 214s] # Construct the error message
[ 214s] template = " Line #%%i (got %%i columns instead of %i)" % nbcols
[ 214s] if skip_footer > 0:
[ 214s] nbinvalid_skipped = len([_ for _ in invalid
[ 214s] if _[0] > nbrows + skip_header])
[ 214s] invalid = invalid[:nbinvalid - nbinvalid_skipped]
[ 214s] skip_footer -= nbinvalid_skipped
[ 214s] #
[ 214s] # nbrows -= skip_footer
[ 214s] # errmsg = [template % (i, nb)
[ 214s] # for (i, nb) in invalid if i < nbrows]
[ 214s] # else:
[ 214s] errmsg = [template % (i, nb)
[ 214s] for (i, nb) in invalid]
[ 214s] if len(errmsg):
[ 214s] errmsg.insert(0, "Some errors were detected !")
[ 214s] errmsg = "\n".join(errmsg)
[ 214s] # Raise an exception ?
[ 214s] if invalid_raise:
[ 214s] raise ValueError(errmsg)
[ 214s] # Issue a warning ?
[ 214s] else:
[ 214s] warnings.warn(errmsg, ConversionWarning, stacklevel=2)
[ 214s]
[ 214s] # Strip the last skip_footer data
[ 214s] if skip_footer > 0:
[ 214s] rows = rows[:-skip_footer]
[ 214s] if usemask:
[ 214s] masks = masks[:-skip_footer]
[ 214s]
[ 214s] # Convert each value according to the converter:
[ 214s] # We want to modify the list in place to avoid creating a new one...
[ 214s] if loose:
[ 214s] rows = list(
[ 214s] zip(*[[conv._loose_call(_r) for _r in map(itemgetter(i), rows)]
[ 214s] for (i, conv) in enumerate(converters)]))
[ 214s] else:
[ 214s] rows = list(
[ 214s] zip(*[[conv._strict_call(_r) for _r in map(itemgetter(i), rows)]
[ 214s] for (i, conv) in enumerate(converters)]))
[ 214s]
[ 214s] # Reset the dtype
[ 214s] data = rows
[ 214s] if dtype is None:
[ 214s] # Get the dtypes from the types of the converters
[ 214s] column_types = [conv.type for conv in converters]
[ 214s] # Find the columns with strings...
[ 214s] strcolidx = [i for (i, v) in enumerate(column_types)
[ 214s] if v == np.unicode_]
[ 214s]
[ 214s] if byte_converters and strcolidx:
[ 214s] # convert strings back to bytes for backward compatibility
[ 214s] warnings.warn(
[ 214s] "Reading unicode strings without specifying the encoding "
[ 214s] "argument is deprecated. Set the encoding, use None for the "
[ 214s] "system default.",
[ 214s] np.VisibleDeprecationWarning, stacklevel=2)
[ 214s] def encode_unicode_cols(row_tup):
[ 214s] row = list(row_tup)
[ 214s] for i in strcolidx:
[ 214s] row[i] = row[i].encode('latin1')
[ 214s] return tuple(row)
[ 214s]
[ 214s] try:
[ 214s] data = [encode_unicode_cols(r) for r in data]
[ 214s] except UnicodeEncodeError:
[ 214s] pass
[ 214s] else:
[ 214s] for i in strcolidx:
[ 214s] column_types[i] = np.bytes_
[ 214s]
[ 214s] # Update string types to be the right length
[ 214s] sized_column_types = column_types[:]
[ 214s] for i, col_type in enumerate(column_types):
[ 214s] if np.issubdtype(col_type, np.character):
[ 214s] n_chars = max(len(row[i]) for row in data)
[ 214s] sized_column_types[i] = (col_type, n_chars)
[ 214s]
[ 214s] if names is None:
[ 214s] # If the dtype is uniform (before sizing strings)
[ 214s] base = {
[ 214s] c_type
[ 214s] for c, c_type in zip(converters, column_types)
[ 214s] if c._checked}
[ 214s] if len(base) == 1:
[ 214s] uniform_type, = base
[ 214s] (ddtype, mdtype) = (uniform_type, bool)
[ 214s] else:
[ 214s] ddtype = [(defaultfmt % i, dt)
[ 214s] for (i, dt) in enumerate(sized_column_types)]
[ 214s] if usemask:
[ 214s] mdtype = [(defaultfmt % i, bool)
[ 214s] for (i, dt) in enumerate(sized_column_types)]
[ 214s] else:
[ 214s] ddtype = list(zip(names, sized_column_types))
[ 214s] mdtype = list(zip(names, [bool] * len(sized_column_types)))
[ 214s] output = np.array(data, dtype=ddtype)
[ 214s] if usemask:
[ 214s] outputmask = np.array(masks, dtype=mdtype)
[ 214s] else:
[ 214s] # Overwrite the initial dtype names if needed
[ 214s] if names and dtype.names is not None:
[ 214s] dtype.names = names
[ 214s] # Case 1. We have a structured type
[ 214s] if len(dtype_flat) > 1:
[ 214s] # Nested dtype, eg [('a', int), ('b', [('b0', int), ('b1', 'f4')])]
[ 214s] # First, create the array using a flattened dtype:
[ 214s] # [('a', int), ('b1', int), ('b2', float)]
[ 214s] # Then, view the array using the specified dtype.
[ 214s] if 'O' in (_.char for _ in dtype_flat):
[ 214s] if has_nested_fields(dtype):
[ 214s] raise NotImplementedError(
[ 214s] "Nested fields involving objects are not supported...")
[ 214s] else:
[ 214s] output = np.array(data, dtype=dtype)
[ 214s] else:
[ 214s] rows = np.array(data, dtype=[('', _) for _ in dtype_flat])
[ 214s] output = rows.view(dtype)
[ 214s] # Now, process the rowmasks the same way
[ 214s] if usemask:
[ 214s] rowmasks = np.array(
[ 214s] masks, dtype=np.dtype([('', bool) for t in dtype_flat]))
[ 214s] # Construct the new dtype
[ 214s] mdtype = make_mask_descr(dtype)
[ 214s] outputmask = rowmasks.view(mdtype)
[ 214s] # Case #2. We have a basic dtype
[ 214s] else:
[ 214s] # We used some user-defined converters
[ 214s] if user_converters:
[ 214s] ishomogeneous = True
[ 214s] descr = []
[ 214s] for i, ttype in enumerate([conv.type for conv in converters]):
[ 214s] # Keep the dtype of the current converter
[ 214s] if i in user_converters:
[ 214s] ishomogeneous &= (ttype == dtype.type)
[ 214s] if np.issubdtype(ttype, np.character):
[ 214s] ttype = (ttype, max(len(row[i]) for row in data))
[ 214s] descr.append(('', ttype))
[ 214s] else:
[ 214s] descr.append(('', dtype))
[ 214s] # So we changed the dtype ?
[ 214s] if not ishomogeneous:
[ 214s] # We have more than one field
[ 214s] if len(descr) > 1:
[ 214s] dtype = np.dtype(descr)
[ 214s] # We have only one field: drop the name if not needed.
[ 214s] else:
[ 214s] dtype = np.dtype(ttype)
[ 214s] #
[ 214s] output = np.array(data, dtype)
[ 214s] if usemask:
[ 214s] if dtype.names is not None:
[ 214s] mdtype = [(_, bool) for _ in dtype.names]
[ 214s] else:
[ 214s] mdtype = bool
[ 214s] outputmask = np.array(masks, dtype=mdtype)
[ 214s] # Try to take care of the missing data we missed
[ 214s] names = output.dtype.names
[ 214s] if usemask and names:
[ 214s] for (name, conv) in zip(names, converters):
[ 214s] missing_values = [conv(_) for _ in conv.missing_values
[ 214s] if _ != '']
[ 214s] for mval in missing_values:
[ 214s] > outputmask[name] |= (output[name] == mval)
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] MaskedArray = <class 'numpy.ma.core.MaskedArray'>
[ 214s] append_to_invalid = <built-in method append of list object at 0xeef255e8>
[ 214s] append_to_masks = <built-in method append of list object at 0xeef25a88>
[ 214s] append_to_rows = <built-in method append of list object at 0xef1d58c8>
[ 214s] autostrip = False
[ 214s] byte_converters = True
[ 214s] case_sensitive = True
[ 214s] comments = '#'
[ 214s] conv = <numpy.lib._iotools.StringConverter object at 0xef20b460>
[ 214s] converters = [<numpy.lib._iotools.StringConverter object at 0xef20b118>, <numpy.lib._iotools.StringConverter object at 0xef20b460>, <numpy.lib._iotools.StringConverter object at 0xef20b4a8>]
[ 214s] data = [(0, 0.0, 0j), (1, nan, 1j), (-9, 2.2, (nan+0j)), (3, -99.0, 3j)]
[ 214s] defaultfmt = 'f%i'
[ 214s] deletechars = " !#$%&'()*+,-./:;<=>?@[\\]^{|}~"
[ 214s] delimiter = ','
[ 214s] dtype = dtype([('A', '<i4'), ('B', '<f8'), ('C', '<c16')])
[ 214s] dtype_flat = [dtype('int32'), dtype('float64'), dtype('complex128')]
[ 214s] encoding = None
[ 214s] excludelist = None
[ 214s] fhd = <numpy.lib.tests.test_io.TextIO object at 0xef530be0>
[ 214s] fid = <numpy.lib.tests.test_io.TextIO object at 0xef530be0>
[ 214s] fid_ctx = <numpy.compat.py3k.contextlib_nullcontext object at 0xef20b070>
[ 214s] filling_values = [None, None, None]
[ 214s] first_line = ''
[ 214s] first_values = ['A', ' B', ' C']
[ 214s] fname = <numpy.lib.tests.test_io.TextIO object at 0xef530be0>
[ 214s] fval = 'A'
[ 214s] i = 4
[ 214s] invalid = []
[ 214s] invalid_raise = True
[ 214s] key = 2
[ 214s] line = b'3, -99, 3j'
[ 214s] loose = True
[ 214s] make_mask_descr = <function make_mask_descr at 0xdcd3e2b0>
[ 214s] masks = [(False, False, False), (False, False, False), (True, False, False), (False, True, False)]
[ 214s] max_rows = None
[ 214s] mdtype = dtype([('A', '?'), ('B', '?'), ('C', '?')])
[ 214s] missing_values = [-99.0]
[ 214s] mval = -99.0
[ 214s] n = 0
[ 214s] name = 'B'
[ 214s] names = ('A', 'B', 'C')
[ 214s] nbcols = 3
[ 214s] nbinvalid = 0
[ 214s] nbvalues = 3
[ 214s] output = array([( 0, 0. , 0.+0.j), ( 1, nan, 0.+1.j), (-9, 2.2, nan+0.j),
[ 214s] ( 3, -99. , 0.+3.j)],
[ 214s] dtype=[('A', '<i4'), ('B', '<f8'), ('C', '<c16')])
[ 214s] outputmask = array([(False, False, False), (False, False, False),
[ 214s] ( True, False, False), (False, True, False)],
[ 214s] dtype=[('A', '?'), ('B', '?'), ('C', '?')])
[ 214s] replace_space = '_'
[ 214s] rowmasks = array([(False, False, False), (False, False, False),
[ 214s] ( True, False, False), (False, True, False)],
[ 214s] dtype=[('f0', '?'), ('f1', '?'), ('f2', '?')])
[ 214s] rows = array([( 0, 0. , 0.+0.j), ( 1, nan, 0.+1.j), (-9, 2.2, nan+0.j),
[ 214s] ( 3, -99. , 0.+3.j)],
[ 214s] dtype=[('f0', '<i4'), ('f1', '<f8'), ('f2', '<c16')])
[ 214s] skip_footer = 0
[ 214s] skip_header = 0
[ 214s] split_line = <numpy.lib._iotools.LineSplitter object at 0xef20b1c0>
[ 214s] uc_update = []
[ 214s] unpack = None
[ 214s] usecols = None
[ 214s] usemask = True
[ 214s] user_converters = {}
[ 214s] user_filling_values = []
[ 214s] user_missing_values = {0: -9, 1: -99, 2: (-0-999j)}
[ 214s] val = ['(-0-999j)']
[ 214s] validate_names = <numpy.lib._iotools.NameValidator object at 0xef20b358>
[ 214s] values = ['3', ' -99', ' 3j']
[ 214s] zipit = <zip object at 0xeef25988>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/npyio.py:2247: DeprecationWarning
[ 214s] _______________________ TestPercentile.test_nan_behavior _______________________
[ 214s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_function_base.TestPercentile object at 0xf1878610>
[ 214s]
[ 214s] def test_nan_behavior(self):
[ 214s] a = np.arange(24, dtype=float)
[ 214s] a[2] = np.nan
[ 214s] assert_equal(np.percentile(a, 0.3), np.nan)
[ 214s] assert_equal(np.percentile(a, 0.3, axis=0), np.nan)
[ 214s] > assert_equal(np.percentile(a, [0.3, 0.6], axis=0),
[ 214s] np.array([np.nan] * 2))
[ 214s]
[ 214s] a = array([ 0., 1., nan, 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
[ 214s] 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23.])
[ 214s] self = <numpy.lib.tests.test_function_base.TestPercentile object at 0xf1878610>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:2912:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan, nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan, nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ____________________ TestNanFunctions_Median.test_mutation _____________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_Median object at 0xf2762cb8>
[ 214s]
[ 214s] def test_mutation(self):
[ 214s] # Check that passed array is not modified.
[ 214s] ndat = _ndat.copy()
[ 214s] np.nanmedian(ndat)
[ 214s] > assert_equal(ndat, _ndat)
[ 214s]
[ 214s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_Median object at 0xf2762cb8>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:599:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ____________________ TestNanFunctions_MinMax.test_mutation _____________________
[ 214s] [gw1] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_MinMax object at 0xdca07538>
[ 214s]
[ 214s] def test_mutation(self):
[ 214s] # Check that passed array is not modified.
[ 214s] ndat = _ndat.copy()
[ 214s] for f in self.nanfuncs:
[ 214s] f(ndat)
[ 214s] > assert_equal(ndat, _ndat)
[ 214s]
[ 214s] f = <function nanmin at 0xddf56538>
[ 214s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_MinMax object at 0xdca07538>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:50:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] __________________________ TestIsclose.test_equal_nan __________________________
[ 214s] [gw0] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf0f19058>
[ 214s]
[ 214s] def test_equal_nan(self):
[ 214s] > assert_array_equal(np.isclose(np.nan, np.nan, equal_nan=True), [True])
[ 214s]
[ 214s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf0f19058>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2199:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] <__array_function__ internals>:5: in isclose
[ 214s] ???
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] a = nan, b = nan, rtol = 1e-05, atol = 1e-08, equal_nan = True
[ 214s]
[ 214s] @array_function_dispatch(_isclose_dispatcher)
[ 214s] def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
[ 214s] """
[ 214s] Returns a boolean array where two arrays are element-wise equal within a
[ 214s] tolerance.
[ 214s]
[ 214s] The tolerance values are positive, typically very small numbers. The
[ 214s] relative difference (`rtol` * abs(`b`)) and the absolute difference
[ 214s] `atol` are added together to compare against the absolute difference
[ 214s] between `a` and `b`.
[ 214s]
[ 214s] .. warning:: The default `atol` is not appropriate for comparing numbers
[ 214s] that are much smaller than one (see Notes).
[ 214s]
[ 214s] Parameters
[ 214s] ----------
[ 214s] a, b : array_like
[ 214s] Input arrays to compare.
[ 214s] rtol : float
[ 214s] The relative tolerance parameter (see Notes).
[ 214s] atol : float
[ 214s] The absolute tolerance parameter (see Notes).
[ 214s] equal_nan : bool
[ 214s] Whether to compare NaN's as equal. If True, NaN's in `a` will be
[ 214s] considered equal to NaN's in `b` in the output array.
[ 214s]
[ 214s] Returns
[ 214s] -------
[ 214s] y : array_like
[ 214s] Returns a boolean array of where `a` and `b` are equal within the
[ 214s] given tolerance. If both `a` and `b` are scalars, returns a single
[ 214s] boolean value.
[ 214s]
[ 214s] See Also
[ 214s] --------
[ 214s] allclose
[ 214s]
[ 214s] Notes
[ 214s] -----
[ 214s] .. versionadded:: 1.7.0
[ 214s]
[ 214s] For finite values, isclose uses the following equation to test whether
[ 214s] two floating point values are equivalent.
[ 214s]
[ 214s] absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
[ 214s]
[ 214s] Unlike the built-in `math.isclose`, the above equation is not symmetric
[ 214s] in `a` and `b` -- it assumes `b` is the reference value -- so that
[ 214s] `isclose(a, b)` might be different from `isclose(b, a)`. Furthermore,
[ 214s] the default value of atol is not zero, and is used to determine what
[ 214s] small values should be considered close to zero. The default value is
[ 214s] appropriate for expected values of order unity: if the expected values
[ 214s] are significantly smaller than one, it can result in false positives.
[ 214s] `atol` should be carefully selected for the use case at hand. A zero value
[ 214s] for `atol` will result in `False` if either `a` or `b` is zero.
[ 214s]
[ 214s] Examples
[ 214s] --------
[ 214s] >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
[ 214s] array([False, True])
[ 214s] >>> np.isclose([1.0, np.nan], [1.0, np.nan])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
[ 214s] array([False, False])
[ 214s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
[ 214s] array([False, True])
[ 214s] """
[ 214s] def within_tol(x, y, atol, rtol):
[ 214s] with errstate(invalid='ignore'):
[ 214s] return less_equal(abs(x-y), atol + rtol * abs(y))
[ 214s]
[ 214s] x = asanyarray(a)
[ 214s] y = asanyarray(b)
[ 214s]
[ 214s] # Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
[ 214s] # This will cause casting of x later. Also, make sure to allow subclasses
[ 214s] # (e.g., for numpy.ma).
[ 214s] dt = multiarray.result_type(y, 1.)
[ 214s] y = array(y, dtype=dt, copy=False, subok=True)
[ 214s]
[ 214s] xfin = isfinite(x)
[ 214s] yfin = isfinite(y)
[ 214s] if all(xfin) and all(yfin):
[ 214s] return within_tol(x, y, atol, rtol)
[ 214s] else:
[ 214s] finite = xfin & yfin
[ 214s] cond = zeros_like(finite, subok=True)
[ 214s] # Because we're using boolean indexing, x & y must be the same shape.
[ 214s] # Ideally, we'd just do x, y = broadcast_arrays(x, y). It's in
[ 214s] # lib.stride_tricks, though, so we can't import it here.
[ 214s] x = x * ones_like(cond)
[ 214s] y = y * ones_like(cond)
[ 214s] # Avoid subtraction with infinite/nan values...
[ 214s] cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
[ 214s] # Check for equality of infinite values...
[ 214s] > cond[~finite] = (x[~finite] == y[~finite])
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] a = nan
[ 214s] atol = 1e-08
[ 214s] b = nan
[ 214s] cond = array(False)
[ 214s] dt = dtype('float64')
[ 214s] equal_nan = True
[ 214s] finite = False
[ 214s] rtol = 1e-05
[ 214s] within_tol = <function isclose.<locals>.within_tol at 0xec6b6148>
[ 214s] x = nan
[ 214s] xfin = False
[ 214s] y = nan
[ 214s] yfin = False
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/numeric.py:2272: DeprecationWarning
[ 214s] _________________ TestNanFunctions_ArgminArgmax.test_mutation __________________
[ 214s] [gw1] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_ArgminArgmax object at 0xf297ebf8>
[ 214s]
[ 214s] def test_mutation(self):
[ 214s] # Check that passed array is not modified.
[ 214s] ndat = _ndat.copy()
[ 214s] for f in self.nanfuncs:
[ 214s] f(ndat)
[ 214s] > assert_equal(ndat, _ndat)
[ 214s]
[ 214s] f = <function nanargmin at 0xddf566e8>
[ 214s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_ArgminArgmax object at 0xf297ebf8>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:183:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestMedian.test_nan_behavior _________________________
[ 214s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_function_base.TestMedian object at 0xf1609be0>
[ 214s]
[ 214s] def test_nan_behavior(self):
[ 214s] a = np.arange(24, dtype=float)
[ 214s] a[2] = np.nan
[ 214s] assert_equal(np.median(a), np.nan)
[ 214s] assert_equal(np.median(a, axis=0), np.nan)
[ 214s]
[ 214s] a = np.arange(24, dtype=float).reshape(2, 3, 4)
[ 214s] a[1, 2, 3] = np.nan
[ 214s] a[1, 1, 2] = np.nan
[ 214s]
[ 214s] # no axis
[ 214s] assert_equal(np.median(a), np.nan)
[ 214s] assert_equal(np.median(a).ndim, 0)
[ 214s]
[ 214s] # axis0
[ 214s] b = np.median(np.arange(24, dtype=float).reshape(2, 3, 4), 0)
[ 214s] b[2, 3] = np.nan
[ 214s] b[1, 2] = np.nan
[ 214s] > assert_equal(np.median(a, 0), b)
[ 214s]
[ 214s] a = array([[[ 0., 1., 2., 3.],
[ 214s] [ 4., 5., 6., 7.],
[ 214s] [ 8., 9., 10., 11.]],
[ 214s]
[ 214s] [[12., 13., 14., 15.],
[ 214s] [16., 17., nan, 19.],
[ 214s] [20., 21., 22., nan]]])
[ 214s] b = array([[ 6., 7., 8., 9.],
[ 214s] [10., 11., nan, 13.],
[ 214s] [14., 15., 16., nan]])
[ 214s] self = <numpy.lib.tests.test_function_base.TestMedian object at 0xf1609be0>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:3147:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 6., 7., 8., 9.],
[ 214s] [10., 11., nan, 13.],
[ 214s] [14., 15., 16., nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 6., 7., 8., 9.],
[ 214s] [10., 11., nan, 13.],
[ 214s] [14., 15., 16., nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestCarg.test_special_values _________________________
[ 214s] [gw0] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath_complex.TestCarg object at 0xf32723b8>
[ 214s]
[ 214s] def test_special_values(self):
[ 214s] # carg(-np.inf +- yi) returns +-pi for finite y > 0
[ 214s] check_real_value(ncu._arg, -np.inf, 1, np.pi, False)
[ 214s] check_real_value(ncu._arg, -np.inf, -1, -np.pi, False)
[ 214s]
[ 214s] # carg(np.inf +- yi) returns +-0 for finite y > 0
[ 214s] check_real_value(ncu._arg, np.inf, 1, np.PZERO, False)
[ 214s] check_real_value(ncu._arg, np.inf, -1, np.NZERO, False)
[ 214s]
[ 214s] # carg(x +- np.infi) returns +-pi/2 for finite x
[ 214s] check_real_value(ncu._arg, 1, np.inf, 0.5 * np.pi, False)
[ 214s] check_real_value(ncu._arg, 1, -np.inf, -0.5 * np.pi, False)
[ 214s]
[ 214s] # carg(-np.inf +- np.infi) returns +-3pi/4
[ 214s] check_real_value(ncu._arg, -np.inf, np.inf, 0.75 * np.pi, False)
[ 214s] check_real_value(ncu._arg, -np.inf, -np.inf, -0.75 * np.pi, False)
[ 214s]
[ 214s] # carg(np.inf +- np.infi) returns +-pi/4
[ 214s] check_real_value(ncu._arg, np.inf, np.inf, 0.25 * np.pi, False)
[ 214s] check_real_value(ncu._arg, np.inf, -np.inf, -0.25 * np.pi, False)
[ 214s]
[ 214s] # carg(x + yi) returns np.nan if x or y is nan
[ 214s] > check_real_value(ncu._arg, np.nan, 0, np.nan, False)
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath_complex.TestCarg object at 0xf32723b8>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath_complex.py:522:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath_complex.py:534: in check_real_value
[ 214s] assert_almost_equal(f(z1), x)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ______________________ TestRegression.test_asfarray_none _______________________
[ 214s] [gw5] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_regression.TestRegression object at 0xf2949c10>
[ 214s]
[ 214s] def test_asfarray_none(self):
[ 214s] # Test for changeset r5065
[ 214s] > assert_array_equal(np.array([np.nan]), np.asfarray([None]))
[ 214s]
[ 214s] self = <numpy.lib.tests.test_regression.TestRegression object at 0xf2949c10>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_regression.py:137:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] __________________ TestNanFunctions_Percentile.test_mutation ___________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_Percentile object at 0xf16bd880>
[ 214s]
[ 214s] def test_mutation(self):
[ 214s] # Check that passed array is not modified.
[ 214s] ndat = _ndat.copy()
[ 214s] np.nanpercentile(ndat, 30)
[ 214s] > assert_equal(ndat, _ndat)
[ 214s]
[ 214s] ndat = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s] self = <numpy.lib.tests.test_nanfunctions.TestNanFunctions_Percentile object at 0xf16bd880>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/lib/tests/test_nanfunctions.py:763:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[ 0.6244, nan, 0.2692, 0.0116, nan, 0.117 ],
[ 214s] [ 0.5351, -0.9403, nan, 0.21 , 0.4759, 0...[ nan, nan, nan, 0.1042, nan, -0.5954],
[ 214s] [ 0.161 , nan, nan, 0.1859, 0.3146, nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ____________________ TestIO.test_io_open_buffered_fromfile _____________________
[ 214s] [gw4] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2b00748>
[ 214s]
[ 214s] def test_io_open_buffered_fromfile(self):
[ 214s] # gh-6632
[ 214s] self.x.tofile(self.filename)
[ 214s] with io.open(self.filename, 'rb', buffering=-1) as f:
[ 214s] y = np.fromfile(f, dtype=self.dtype)
[ 214s] > assert_array_equal(y, self.x.flat)
[ 214s]
[ 214s] f = <_io.BufferedReader name='/tmp/tmpfbama4ya/tmpvmawrjvz'>
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf2b00748>
[ 214s] y = array([0.62708559+0.79704411j, nan+0.j ,
[ 214s] 0.04195581+0.54502309j, 0.75747277+0.56422699j,
[ 214s] ...568644j,
[ 214s] 0.25755049+0.072916j , 0.34260646+0.37851684j,
[ 214s] 0.00614414+0.46108903j, 0.43855106+0.77854045j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4773:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([0.62708559+0.79704411j, nan+0.j ,
[ 214s] 0.04195581+0.54502309j, 0.75747277+0.56422699j,
[ 214s] ...568644j,
[ 214s] 0.25755049+0.072916j , 0.34260646+0.37851684j,
[ 214s] 0.00614414+0.46108903j, 0.43855106+0.77854045j])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([0.62708559+0.79704411j, nan+0.j ,
[ 214s] 0.04195581+0.54502309j, 0.75747277+0.56422699j,
[ 214s] ...568644j,
[ 214s] 0.25755049+0.072916j , 0.34260646+0.37851684j,
[ 214s] 0.00614414+0.46108903j, 0.43855106+0.77854045j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _____________________________ TestMedian.test_nan ______________________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf2734118>
[ 214s]
[ 214s] def test_nan(self):
[ 214s] for mask in (False, np.zeros(6, dtype=bool)):
[ 214s] dm = np.ma.array([[1, np.nan, 3], [1, 2, 3]])
[ 214s] dm.mask = mask
[ 214s]
[ 214s] # scalar result
[ 214s] r = np.ma.median(dm, axis=None)
[ 214s] assert_(np.isscalar(r))
[ 214s] > assert_array_equal(r, np.nan)
[ 214s]
[ 214s] dm = masked_array(
[ 214s] data=[[1.0, nan, 3.0],
[ 214s] [1.0, 2.0, 3.0]],
[ 214s] mask=[[False, False, False],
[ 214s] [False, False, False]],
[ 214s] fill_value=1e+20)
[ 214s] mask = False
[ 214s] r = nan
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf2734118>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/tests/test_extras.py:914:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:227: in assert_array_equal
[ 214s] assert_array_compare(operator.__eq__, x, y,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:215: in assert_array_compare
[ 214s] return np.testing.assert_array_compare(comparison,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array(nan)
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array(nan)
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ test_array_almost_equal_matrix ________________________
[ 214s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] def test_array_almost_equal_matrix():
[ 214s] # Matrix slicing keeps things 2-D, while array does not necessarily.
[ 214s] # See gh-8452.
[ 214s] # 2018-04-29: moved here from testing.tests.test_utils.
[ 214s] m1 = np.matrix([[1., 2.]])
[ 214s] m2 = np.matrix([[1., np.nan]])
[ 214s] m3 = np.matrix([[1., -np.inf]])
[ 214s] m4 = np.matrix([[np.nan, np.inf]])
[ 214s] m5 = np.matrix([[1., 2.], [np.nan, np.inf]])
[ 214s] for assert_func in assert_array_almost_equal, assert_almost_equal:
[ 214s] for m in m1, m2, m3, m4, m5:
[ 214s] > assert_func(m, m)
[ 214s]
[ 214s] a = array([[1., 2.]])
[ 214s] assert_func = <function assert_array_almost_equal at 0xdcaa86a0>
[ 214s] m = matrix([[ 1., nan]])
[ 214s] m1 = matrix([[1., 2.]])
[ 214s] m2 = matrix([[ 1., nan]])
[ 214s] m3 = matrix([[ 1., -inf]])
[ 214s] m4 = matrix([[nan, inf]])
[ 214s] m5 = matrix([[ 1., 2.],
[ 214s] [nan, inf]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/matrixlib/tests/test_interaction.py:360:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = matrix([[ 1., nan]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = matrix([[ 1., nan]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ___________________________ TestMedian.test_out_nan ____________________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf1638460>
[ 214s]
[ 214s] def test_out_nan(self):
[ 214s] o = np.ma.masked_array(np.zeros((4,)))
[ 214s] d = np.ma.masked_array(np.ones((3, 4)))
[ 214s] d[2, 1] = np.nan
[ 214s] d[2, 2] = np.ma.masked
[ 214s] > assert_equal(np.ma.median(d, 0, out=o), o)
[ 214s]
[ 214s] d = masked_array(
[ 214s] data=[[1.0, 1.0, 1.0, 1.0],
[ 214s] [1.0, 1.0, 1.0, 1.0],
[ 214s] [1.0, nan, --, 1.0]],
[ 214s] mask=[[False, False, False, False],
[ 214s] [False, False, False, False],
[ 214s] [False, False, True, False]],
[ 214s] fill_value=1e+20)
[ 214s] o = masked_array(data=[1.0, nan, 1.0, 1.0],
[ 214s] mask=[False, False, False, False],
[ 214s] fill_value=1e+20)
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf1638460>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/tests/test_extras.py:940:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:146: in assert_equal
[ 214s] return assert_array_equal(actual, desired, err_msg)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:227: in assert_array_equal
[ 214s] assert_array_compare(operator.__eq__, x, y,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:215: in assert_array_compare
[ 214s] return np.testing.assert_array_compare(comparison,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([ 1., nan, 1., 1.])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([ 1., nan, 1., 1.])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestMedian.test_nan_behavior _________________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf16bd850>
[ 214s]
[ 214s] def test_nan_behavior(self):
[ 214s] a = np.ma.masked_array(np.arange(24, dtype=float))
[ 214s] a[::3] = np.ma.masked
[ 214s] a[2] = np.nan
[ 214s] > assert_array_equal(np.ma.median(a), np.nan)
[ 214s]
[ 214s] a = masked_array(data=[--, 1.0, nan, --, 4.0, 5.0, --, 7.0, 8.0, --, 10.0,
[ 214s] 11.0, --, 13.0, 14.0, --, 16...lse, False, True,
[ 214s] False, False, True, False, False, True, False, False],
[ 214s] fill_value=1e+20)
[ 214s] self = <numpy.ma.tests.test_extras.TestMedian object at 0xf16bd850>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/tests/test_extras.py:950:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:227: in assert_array_equal
[ 214s] assert_array_compare(operator.__eq__, x, y,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/ma/testutils.py:215: in assert_array_compare
[ 214s] return np.testing.assert_array_compare(comparison,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array(nan)
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array(nan)
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ______________________ TestArrayEqual.test_masked_nan_inf ______________________
[ 214s] [gw0] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayEqual object at 0xf0935cb8>
[ 214s]
[ 214s] def test_masked_nan_inf(self):
[ 214s] # Regression test for gh-11121
[ 214s] a = np.ma.MaskedArray([3., 4., 6.5], mask=[False, True, False])
[ 214s] b = np.array([3., np.nan, 6.5])
[ 214s] > self._test_equal(a, b)
[ 214s]
[ 214s] a = masked_array(data=[3.0, --, 6.5],
[ 214s] mask=[False, True, False],
[ 214s] fill_value=1e+20)
[ 214s] b = array([3. , nan, 6.5])
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayEqual object at 0xf0935cb8>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:170:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:26: in _test_equal
[ 214s] self._assert_func(a, b)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:729: in func_assert_same_pos
[ 214s] y_id = func(y)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([3. , nan, 6.5])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([3. , nan, 6.5])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ TestArrayEqual.test_nan_array _________________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayEqual object at 0xf21bc2e0>
[ 214s]
[ 214s] def test_nan_array(self):
[ 214s] """Test arrays with nan values in them."""
[ 214s] a = np.array([1, 2, np.nan])
[ 214s] b = np.array([1, 2, np.nan])
[ 214s]
[ 214s] > self._test_equal(a, b)
[ 214s]
[ 214s] a = array([ 1., 2., nan])
[ 214s] b = array([ 1., 2., nan])
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayEqual object at 0xf21bc2e0>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:132:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:26: in _test_equal
[ 214s] self._assert_func(a, b)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([ 1., 2., nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([ 1., 2., nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ___________________________ TestEqual.test_nan_array ___________________________
[ 214s] [gw10] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf2270b08>
[ 214s]
[ 214s] def test_nan_array(self):
[ 214s] """Test arrays with nan values in them."""
[ 214s] a = np.array([1, 2, np.nan])
[ 214s] b = np.array([1, 2, np.nan])
[ 214s]
[ 214s] > self._test_equal(a, b)
[ 214s]
[ 214s] a = array([ 1., 2., nan])
[ 214s] b = array([ 1., 2., nan])
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf2270b08>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:132:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:26: in _test_equal
[ 214s] self._assert_func(a, b)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([ 1., 2., nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([ 1., 2., nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ____________________________ TestEqual.test_complex ____________________________
[ 214s] [gw3] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf13b9b20>
[ 214s]
[ 214s] def test_complex(self):
[ 214s] x = np.array([complex(1, 2), complex(1, np.nan)])
[ 214s] y = np.array([complex(1, 2), complex(1, 2)])
[ 214s] > self._assert_func(x, x)
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf13b9b20>
[ 214s] x = array([1. +2.j, 1.+nanj])
[ 214s] y = array([1.+2.j, 1.+2.j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:343:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([1. +2.j, 1.+nanj])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([1. +2.j, 1.+nanj])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ TestEqual.test_masked_nan_inf _________________________
[ 214s] [gw13] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf1991760>
[ 214s]
[ 214s] def test_masked_nan_inf(self):
[ 214s] # Regression test for gh-11121
[ 214s] a = np.ma.MaskedArray([3., 4., 6.5], mask=[False, True, False])
[ 214s] b = np.array([3., np.nan, 6.5])
[ 214s] > self._test_equal(a, b)
[ 214s]
[ 214s] a = masked_array(data=[3.0, --, 6.5],
[ 214s] mask=[False, True, False],
[ 214s] fill_value=1e+20)
[ 214s] b = array([3. , nan, 6.5])
[ 214s] self = <numpy.testing.tests.test_utils.TestEqual object at 0xf1991760>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:170:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:26: in _test_equal
[ 214s] self._assert_func(a, b)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:729: in func_assert_same_pos
[ 214s] y_id = func(y)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([3. , nan, 6.5])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([3. , nan, 6.5])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ TestArrayAlmostEqual.test_nan _________________________
[ 214s] [gw14] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayAlmostEqual object at 0xef7f1688>
[ 214s]
[ 214s] def test_nan(self):
[ 214s] anan = np.array([np.nan])
[ 214s] aone = np.array([1])
[ 214s] ainf = np.array([np.inf])
[ 214s] > self._assert_func(anan, anan)
[ 214s]
[ 214s] ainf = array([inf])
[ 214s] anan = array([nan])
[ 214s] aone = array([1])
[ 214s] self = <numpy.testing.tests.test_utils.TestArrayAlmostEqual object at 0xef7f1688>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:407:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestAlmostEqual.test_complex _________________________
[ 214s] [gw0] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestAlmostEqual object at 0xf0949b08>
[ 214s]
[ 214s] def test_complex(self):
[ 214s] x = np.array([complex(1, 2), complex(1, np.nan)])
[ 214s] z = np.array([complex(1, 2), complex(np.nan, 1)])
[ 214s] y = np.array([complex(1, 2), complex(1, 2)])
[ 214s] > self._assert_func(x, x)
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestAlmostEqual object at 0xf0949b08>
[ 214s] x = array([1. +2.j, 1.+nanj])
[ 214s] y = array([1.+2.j, 1.+2.j])
[ 214s] z = array([ 1.+2.j, nan+1.j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:524:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([ 2., nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([ 2., nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] __________________ TestAssertAllclose.test_equal_nan_default ___________________
[ 214s] [gw15] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf21d6670>
[ 214s]
[ 214s] def test_equal_nan_default(self):
[ 214s] # Make sure equal_nan default behavior remains unchanged. (All
[ 214s] # of these functions use assert_array_compare under the hood.)
[ 214s] # None of these should raise.
[ 214s] a = np.array([np.nan])
[ 214s] b = np.array([np.nan])
[ 214s] > assert_array_equal(a, b)
[ 214s]
[ 214s] a = array([nan])
[ 214s] b = array([nan])
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf21d6670>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:914:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ______________________ TestAssertAllclose.test_equal_nan _______________________
[ 214s] [gw10] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf25122b0>
[ 214s]
[ 214s] def test_equal_nan(self):
[ 214s] a = np.array([np.nan])
[ 214s] b = np.array([np.nan])
[ 214s] # Should not raise:
[ 214s] > assert_allclose(a, b, equal_nan=True)
[ 214s]
[ 214s] a = array([nan])
[ 214s] b = array([nan])
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf25122b0>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:901:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ____________________ TestAssertAllclose.test_not_equal_nan _____________________
[ 214s] [gw4] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf215b5f8>
[ 214s]
[ 214s] def test_not_equal_nan(self):
[ 214s] a = np.array([np.nan])
[ 214s] b = np.array([np.nan])
[ 214s] > assert_raises(AssertionError, assert_allclose, a, b, equal_nan=False)
[ 214s]
[ 214s] a = array([nan])
[ 214s] b = array([nan])
[ 214s] self = <numpy.testing.tests.test_utils.TestAssertAllclose object at 0xf215b5f8>
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/tests/test_utils.py:906:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] /usr/lib/python3.8/unittest/case.py:816: in assertRaises
[ 214s] return context.handle('assertRaises', args, kwargs)
[ 214s] /usr/lib/python3.8/unittest/case.py:202: in handle
[ 214s] callable_obj(*args, **kwargs)
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:1532: in assert_allclose
[ 214s] assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:773: in assert_array_compare
[ 214s] flagged |= func_assert_same_pos(x, y,
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestHeavside.test_heaviside __________________________
[ 214s] [gw6] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath.TestHeavside object at 0xf2decb50>
[ 214s]
[ 214s] def test_heaviside(self):
[ 214s] x = np.array([[-30.0, -0.1, 0.0, 0.2], [7.5, np.nan, np.inf, -np.inf]])
[ 214s] expectedhalf = np.array([[0.0, 0.0, 0.5, 1.0], [1.0, np.nan, 1.0, 0.0]])
[ 214s] expected1 = expectedhalf.copy()
[ 214s] expected1[0, 2] = 1
[ 214s]
[ 214s] h = ncu.heaviside(x, 0.5)
[ 214s] > assert_equal(h, expectedhalf)
[ 214s]
[ 214s] expected1 = array([[ 0., 0., 1., 1.],
[ 214s] [ 1., nan, 1., 0.]])
[ 214s] expectedhalf = array([[0. , 0. , 0.5, 1. ],
[ 214s] [1. , nan, 1. , 0. ]])
[ 214s] h = array([[0. , 0. , 0.5, 1. ],
[ 214s] [1. , nan, 1. , 0. ]])
[ 214s] self = <numpy.core.tests.test_umath.TestHeavside object at 0xf2decb50>
[ 214s] x = array([[-30. , -0.1, 0. , 0.2],
[ 214s] [ 7.5, nan, inf, -inf]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:1433:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([[0. , 0. , 0.5, 1. ],
[ 214s] [1. , nan, 1. , 0. ]])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([[0. , 0. , 0.5, 1. ],
[ 214s] [1. , nan, 1. , 0. ]])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] __________________ TestAbsoluteNegative.test_abs_neg_blocked ___________________
[ 214s] [gw6] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath.TestAbsoluteNegative object at 0xf2e46ac0>
[ 214s]
[ 214s] def test_abs_neg_blocked(self):
[ 214s] # simd tests on abs, test all alignments for vz + 2 * (vs - 1) + 1
[ 214s] for dt, sz in [(np.float32, 11), (np.float64, 5)]:
[ 214s] for out, inp, msg in _gen_alignment_data(dtype=dt, type='unary',
[ 214s] max_size=sz):
[ 214s] tgt = [ncu.absolute(i) for i in inp]
[ 214s] np.absolute(inp, out=out)
[ 214s] assert_equal(out, tgt, err_msg=msg)
[ 214s] assert_((out >= 0).all())
[ 214s]
[ 214s] tgt = [-1*(i) for i in inp]
[ 214s] np.negative(inp, out=out)
[ 214s] assert_equal(out, tgt, err_msg=msg)
[ 214s]
[ 214s] for v in [np.nan, -np.inf, np.inf]:
[ 214s] for i in range(inp.size):
[ 214s] d = np.arange(inp.size, dtype=dt)
[ 214s] inp[:] = -d
[ 214s] inp[i] = v
[ 214s] d[i] = -v if v == -np.inf else v
[ 214s] > assert_array_equal(np.abs(inp), d, err_msg=msg)
[ 214s]
[ 214s] d = array([nan, 1.], dtype=float32)
[ 214s] dt = <class 'numpy.float32'>
[ 214s] i = 0
[ 214s] inp = array([nan, -1.], dtype=float32)
[ 214s] msg = "unary offset=(0, 0), size=2, dtype=<class 'numpy.float32'>, out of place"
[ 214s] out = array([-0., -1.], dtype=float32)
[ 214s] self = <numpy.core.tests.test_umath.TestAbsoluteNegative object at 0xf2e46ac0>
[ 214s] sz = 11
[ 214s] tgt = [-0.0, -1.0]
[ 214s] v = nan
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:1542:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan, 1.], dtype=float32)
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan, 1.], dtype=float32)
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestClog.test_special_values _________________________
[ 214s] [gw6] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath_complex.TestClog object at 0xf2831358>
[ 214s]
[ 214s] @platform_skip
[ 214s] @pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
[ 214s] def test_special_values(self):
[ 214s] xl = []
[ 214s] yl = []
[ 214s]
[ 214s] # From C99 std (Sec 6.3.2)
[ 214s] # XXX: check exceptions raised
[ 214s] # --- raise for invalid fails.
[ 214s]
[ 214s] # clog(-0 + i0) returns -inf + i pi and raises the 'divide-by-zero'
[ 214s] # floating-point exception.
[ 214s] with np.errstate(divide='raise'):
[ 214s] x = np.array([np.NZERO], dtype=complex)
[ 214s] y = complex(-np.inf, np.pi)
[ 214s] assert_raises(FloatingPointError, np.log, x)
[ 214s] with np.errstate(divide='ignore'):
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s]
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(+0 + i0) returns -inf + i0 and raises the 'divide-by-zero'
[ 214s] # floating-point exception.
[ 214s] with np.errstate(divide='raise'):
[ 214s] x = np.array([0], dtype=complex)
[ 214s] y = complex(-np.inf, 0)
[ 214s] assert_raises(FloatingPointError, np.log, x)
[ 214s] with np.errstate(divide='ignore'):
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s]
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(x + i inf returns +inf + i pi /2, for finite x.
[ 214s] x = np.array([complex(1, np.inf)], dtype=complex)
[ 214s] y = complex(np.inf, 0.5 * np.pi)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] x = np.array([complex(-1, np.inf)], dtype=complex)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(x + iNaN) returns NaN + iNaN and optionally raises the
[ 214s] # 'invalid' floating- point exception, for finite x.
[ 214s] with np.errstate(invalid='raise'):
[ 214s] x = np.array([complex(1., np.nan)], dtype=complex)
[ 214s] y = complex(np.nan, np.nan)
[ 214s] #assert_raises(FloatingPointError, np.log, x)
[ 214s] with np.errstate(invalid='ignore'):
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s]
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] with np.errstate(invalid='raise'):
[ 214s] x = np.array([np.inf + 1j * np.nan], dtype=complex)
[ 214s] #assert_raises(FloatingPointError, np.log, x)
[ 214s] with np.errstate(invalid='ignore'):
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s]
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(- inf + iy) returns +inf + ipi , for finite positive-signed y.
[ 214s] x = np.array([-np.inf + 1j], dtype=complex)
[ 214s] y = complex(np.inf, np.pi)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(+ inf + iy) returns +inf + i0, for finite positive-signed y.
[ 214s] x = np.array([np.inf + 1j], dtype=complex)
[ 214s] y = complex(np.inf, 0)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(- inf + i inf) returns +inf + i3pi /4.
[ 214s] x = np.array([complex(-np.inf, np.inf)], dtype=complex)
[ 214s] y = complex(np.inf, 0.75 * np.pi)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(+ inf + i inf) returns +inf + ipi /4.
[ 214s] x = np.array([complex(np.inf, np.inf)], dtype=complex)
[ 214s] y = complex(np.inf, 0.25 * np.pi)
[ 214s] assert_almost_equal(np.log(x), y)
[ 214s] xl.append(x)
[ 214s] yl.append(y)
[ 214s]
[ 214s] # clog(+/- inf + iNaN) returns +inf + iNaN.
[ 214s] x = np.array([complex(np.inf, np.nan)], dtype=complex)
[ 214s] y = complex(np.inf, np.nan)
[ 214s] > assert_almost_equal(np.log(x), y)
[ 214s]
[ 214s] self = <numpy.core.tests.test_umath_complex.TestClog object at 0xf2831358>
[ 214s] x = array([inf+nanj])
[ 214s] xl = [array([-0.+0.j]), array([0.+0.j]), array([1.+infj]), array([-1.+infj]), array([1.+nanj]), array([nan+nanj]), ...]
[ 214s] y = (inf+nanj)
[ 214s] yl = [(-inf+3.141592653589793j), (-inf+0j), (inf+1.5707963267948966j), (inf+1.5707963267948966j), (nan+nanj), (nan+nanj), ...]
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_umath_complex.py:240:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([nan])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([nan])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ TestIO.test_roundtrip_filename ________________________
[ 214s] [gw11] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3423a30>
[ 214s]
[ 214s] def test_roundtrip_filename(self):
[ 214s] self.x.tofile(self.filename)
[ 214s] y = np.fromfile(self.filename, dtype=self.dtype)
[ 214s] > assert_array_equal(y, self.x.flat)
[ 214s]
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3423a30>
[ 214s] y = array([0.43749275+0.90212882j, nan+0.j ,
[ 214s] 0.77386096+0.12858426j, 0.13177647+0.31787579j,
[ 214s] ...15714j ,
[ 214s] 0.76803089+0.44294568j, 0.19436815+0.57949344j,
[ 214s] 0.86287077+0.61756091j, 0.02872195+0.17711749j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4689:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([0.43749275+0.90212882j, nan+0.j ,
[ 214s] 0.77386096+0.12858426j, 0.13177647+0.31787579j,
[ 214s] ...15714j ,
[ 214s] 0.76803089+0.44294568j, 0.19436815+0.57949344j,
[ 214s] 0.86287077+0.61756091j, 0.02872195+0.17711749j])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([0.43749275+0.90212882j, nan+0.j ,
[ 214s] 0.77386096+0.12858426j, 0.13177647+0.31787579j,
[ 214s] ...15714j ,
[ 214s] 0.76803089+0.44294568j, 0.19436815+0.57949344j,
[ 214s] 0.86287077+0.61756091j, 0.02872195+0.17711749j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ________________________ TestIO.test_roundtrip_pathlib _________________________
[ 214s] [gw12] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3423ef8>
[ 214s]
[ 214s] @pytest.mark.skipif(pathlib is None, reason="pathlib not found")
[ 214s] def test_roundtrip_pathlib(self):
[ 214s] p = pathlib.Path(self.filename)
[ 214s] self.x.tofile(p)
[ 214s] y = np.fromfile(p, dtype=self.dtype)
[ 214s] > assert_array_equal(y, self.x.flat)
[ 214s]
[ 214s] p = PosixPath('/tmp/tmp3cmfxevh/tmpp4egzum9')
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf3423ef8>
[ 214s] y = array([0.50755507+0.84602469j, nan+0.j ,
[ 214s] 0.43352176+0.90255503j, 0.44631306+0.22599553j,
[ 214s] ...123164j,
[ 214s] 0.17873977+0.9384556j , 0.01220009+0.93864246j,
[ 214s] 0.45699848+0.74504455j, 0.93175194+0.91073504j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4696:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([0.50755507+0.84602469j, nan+0.j ,
[ 214s] 0.43352176+0.90255503j, 0.44631306+0.22599553j,
[ 214s] ...123164j,
[ 214s] 0.17873977+0.9384556j , 0.01220009+0.93864246j,
[ 214s] 0.45699848+0.74504455j, 0.93175194+0.91073504j])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([0.50755507+0.84602469j, nan+0.j ,
[ 214s] 0.43352176+0.90255503j, 0.44631306+0.22599553j,
[ 214s] ...123164j,
[ 214s] 0.17873977+0.9384556j , 0.01220009+0.93864246j,
[ 214s] 0.45699848+0.74504455j, 0.93175194+0.91073504j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] _________________________ TestIsclose.test_ip_isclose __________________________
[ 214s] [gw12] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf2266580>
[ 214s]
[ 214s] def test_ip_isclose(self):
[ 214s] self.setup()
[ 214s] tests = self.some_close_tests
[ 214s] results = self.some_close_results
[ 214s] for (x, y), result in zip(tests, results):
[ 214s] > assert_array_equal(np.isclose(x, y), result)
[ 214s]
[ 214s] result = [True, False, False]
[ 214s] results = [[True, False], [True, False, False], [True, True, False], [False, False, False], [True, False, False, False], [True, False, False, False]]
[ 214s] self = <numpy.core.tests.test_numeric.TestIsclose object at 0xf2266580>
[ 214s] tests = [([inf, 0], [inf, 2e-08]), ([1e-08, 1, 1000020.0000000099], [0, nan, 1000000.0]), (array([0, 1, 2]), [0, 1, 2.1]), (nan, [nan, nan, nan]), ([0], [1e-08, inf, -inf, nan]), (0, [1e-08, inf, -inf, nan])]
[ 214s] x = [1e-08, 1, 1000020.0000000099]
[ 214s] y = [0, nan, 1000000.0]
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2164:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] <__array_function__ internals>:5: in isclose
[ 214s] ???
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] a = [1e-08, 1, 1000020.0000000099], b = [0, nan, 1000000.0], rtol = 1e-05
[ 214s] atol = 1e-08, equal_nan = False
[ 214s]
[ 214s] @array_function_dispatch(_isclose_dispatcher)
[ 214s] def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
[ 214s] """
[ 214s] Returns a boolean array where two arrays are element-wise equal within a
[ 214s] tolerance.
[ 214s]
[ 214s] The tolerance values are positive, typically very small numbers. The
[ 214s] relative difference (`rtol` * abs(`b`)) and the absolute difference
[ 214s] `atol` are added together to compare against the absolute difference
[ 214s] between `a` and `b`.
[ 214s]
[ 214s] .. warning:: The default `atol` is not appropriate for comparing numbers
[ 214s] that are much smaller than one (see Notes).
[ 214s]
[ 214s] Parameters
[ 214s] ----------
[ 214s] a, b : array_like
[ 214s] Input arrays to compare.
[ 214s] rtol : float
[ 214s] The relative tolerance parameter (see Notes).
[ 214s] atol : float
[ 214s] The absolute tolerance parameter (see Notes).
[ 214s] equal_nan : bool
[ 214s] Whether to compare NaN's as equal. If True, NaN's in `a` will be
[ 214s] considered equal to NaN's in `b` in the output array.
[ 214s]
[ 214s] Returns
[ 214s] -------
[ 214s] y : array_like
[ 214s] Returns a boolean array of where `a` and `b` are equal within the
[ 214s] given tolerance. If both `a` and `b` are scalars, returns a single
[ 214s] boolean value.
[ 214s]
[ 214s] See Also
[ 214s] --------
[ 214s] allclose
[ 214s]
[ 214s] Notes
[ 214s] -----
[ 214s] .. versionadded:: 1.7.0
[ 214s]
[ 214s] For finite values, isclose uses the following equation to test whether
[ 214s] two floating point values are equivalent.
[ 214s]
[ 214s] absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
[ 214s]
[ 214s] Unlike the built-in `math.isclose`, the above equation is not symmetric
[ 214s] in `a` and `b` -- it assumes `b` is the reference value -- so that
[ 214s] `isclose(a, b)` might be different from `isclose(b, a)`. Furthermore,
[ 214s] the default value of atol is not zero, and is used to determine what
[ 214s] small values should be considered close to zero. The default value is
[ 214s] appropriate for expected values of order unity: if the expected values
[ 214s] are significantly smaller than one, it can result in false positives.
[ 214s] `atol` should be carefully selected for the use case at hand. A zero value
[ 214s] for `atol` will result in `False` if either `a` or `b` is zero.
[ 214s]
[ 214s] Examples
[ 214s] --------
[ 214s] >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
[ 214s] array([False, True])
[ 214s] >>> np.isclose([1.0, np.nan], [1.0, np.nan])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
[ 214s] array([ True, False])
[ 214s] >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
[ 214s] array([False, False])
[ 214s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
[ 214s] array([ True, True])
[ 214s] >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
[ 214s] array([False, True])
[ 214s] """
[ 214s] def within_tol(x, y, atol, rtol):
[ 214s] with errstate(invalid='ignore'):
[ 214s] return less_equal(abs(x-y), atol + rtol * abs(y))
[ 214s]
[ 214s] x = asanyarray(a)
[ 214s] y = asanyarray(b)
[ 214s]
[ 214s] # Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
[ 214s] # This will cause casting of x later. Also, make sure to allow subclasses
[ 214s] # (e.g., for numpy.ma).
[ 214s] dt = multiarray.result_type(y, 1.)
[ 214s] y = array(y, dtype=dt, copy=False, subok=True)
[ 214s]
[ 214s] xfin = isfinite(x)
[ 214s] yfin = isfinite(y)
[ 214s] if all(xfin) and all(yfin):
[ 214s] return within_tol(x, y, atol, rtol)
[ 214s] else:
[ 214s] finite = xfin & yfin
[ 214s] cond = zeros_like(finite, subok=True)
[ 214s] # Because we're using boolean indexing, x & y must be the same shape.
[ 214s] # Ideally, we'd just do x, y = broadcast_arrays(x, y). It's in
[ 214s] # lib.stride_tricks, though, so we can't import it here.
[ 214s] x = x * ones_like(cond)
[ 214s] y = y * ones_like(cond)
[ 214s] # Avoid subtraction with infinite/nan values...
[ 214s] cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
[ 214s] # Check for equality of infinite values...
[ 214s] > cond[~finite] = (x[~finite] == y[~finite])
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] a = [1e-08, 1, 1000020.0000000099]
[ 214s] atol = 1e-08
[ 214s] b = [0, nan, 1000000.0]
[ 214s] cond = array([ True, False, False])
[ 214s] dt = dtype('float64')
[ 214s] equal_nan = False
[ 214s] finite = array([ True, False, True])
[ 214s] rtol = 1e-05
[ 214s] within_tol = <function isclose.<locals>.within_tol at 0xf2f55028>
[ 214s] x = array([1.00000e-08, 1.00000e+00, 1.00002e+06])
[ 214s] xfin = array([ True, True, True])
[ 214s] y = array([ 0., nan, 1000000.])
[ 214s] yfin = array([ True, False, True])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/numeric.py:2272: DeprecationWarning
[ 214s] _________________________ TestIO.test_fromfile_offset __________________________
[ 214s] [gw8] linux -- Python 3.8.2 /usr/bin/python3
[ 214s] RuntimeWarning: invalid value encountered in equal
[ 214s]
[ 214s] The above exception was the direct cause of the following exception:
[ 214s]
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf1b92838>
[ 214s]
[ 214s] def test_fromfile_offset(self):
[ 214s] with open(self.filename, 'wb') as f:
[ 214s] self.x.tofile(f)
[ 214s]
[ 214s] with open(self.filename, 'rb') as f:
[ 214s] y = np.fromfile(f, dtype=self.dtype, offset=0)
[ 214s] > assert_array_equal(y, self.x.flat)
[ 214s]
[ 214s] f = <_io.BufferedReader name='/tmp/tmpn37a19hc/tmp4fmcye1x'>
[ 214s] self = <numpy.core.tests.test_multiarray.TestIO object at 0xf1b92838>
[ 214s] y = array([0.5419866 +0.9720607j , nan+0.j ,
[ 214s] 0.32325877+0.18744969j, 0.09744198+0.21489513j,
[ 214s] ...101885j,
[ 214s] 0.71100761+0.82273991j, 0.49304837+0.24019493j,
[ 214s] 0.32644148+0.00969028j, 0.11585306+0.22504173j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/core/tests/test_multiarray.py:4843:
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:728: in func_assert_same_pos
[ 214s] x_id = func(x)
[ 214s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 214s]
[ 214s] xy = array([0.5419866 +0.9720607j , nan+0.j ,
[ 214s] 0.32325877+0.18744969j, 0.09744198+0.21489513j,
[ 214s] ...101885j,
[ 214s] 0.71100761+0.82273991j, 0.49304837+0.24019493j,
[ 214s] 0.32644148+0.00969028j, 0.11585306+0.22504173j])
[ 214s]
[ 214s] > func=lambda xy: xy == +inf,
[ 214s] hasval='+inf')
[ 214s] E DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
[ 214s]
[ 214s] inf = inf
[ 214s] xy = array([0.5419866 +0.9720607j , nan+0.j ,
[ 214s] 0.32325877+0.18744969j, 0.09744198+0.21489513j,
[ 214s] ...101885j,
[ 214s] 0.71100761+0.82273991j, 0.49304837+0.24019493j,
[ 214s] 0.32644148+0.00969028j, 0.11585306+0.22504173j])
[ 214s]
[ 214s] ../../../BUILDROOT/python-numpy-1.18.3-0.i386/usr/lib/python3.8/site-packages/numpy/testing/_private/utils.py:774: DeprecationWarning
[ 214s] ===== 70 failed, 9903 passed, 560 skipped, 20 xfailed, 2 xpassed in 59.15s =====
[ 214s] error: Bad exit status from /var/tmp/rpm-tmp.LieQNI (%check)
[ 214s]
[ 214s]
[ 214s] RPM build errors:
[ 214s] Bad exit status from /var/tmp/rpm-tmp.LieQNI (%check)
[ 214s]
[ 214s] marxinbox.suse.cz failed "build python-numpy.spec" at Tue May 12 09:19:47 UTC 2020.
[ 214s]
The buildroot was: /var/tmp/build-root/openSUSE_Factory-i586
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment