scipy: test_tolerance_float32 failures with MKL 2018.2

After installing scipy-1.4.1 ran scipy.test(). Got a bunch of errors under “test_bumpy_deprecation”

=================================== FAILURES ===================================
_________________________ test_numpy_deprecation[fft] __________________________

key = 'fft'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = [1.0, 0.0]
dep        = None
func       = <module 'scipy.fft' from '/home/bernard/.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/fft/__init__.py'>
key        = 'fft'
match      = 'scipy\\.fft.*deprecated.*1.5.0.*'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
_________________________ test_numpy_deprecation[ifft] _________________________

key = 'ifft'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = [1.0, 0.0]
dep        = None
func       = <function ifft at 0x7fa7a21c5d90>
key        = 'ifft'
match      = 'scipy\\.ifft is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
_________________________ test_numpy_deprecation[diag] _________________________

key = 'diag'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = [1.0, 0.0]
dep        = None
func       = <function diag at 0x7fa7a21b8950>
key        = 'diag'
match      = 'scipy\\.diag is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
________________________ test_numpy_deprecation[arccos] ________________________

key = 'arccos'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = [1.0, 0.0]
dep        = None
func       = <function arccos at 0x7fa7a21a0a60>
key        = 'arccos'
match      = 'scipy\\.arccos is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
________________________ test_numpy_deprecation[randn] _________________________

key = 'randn'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = 2
dep        = None
func       = <function RandomState.randn at 0x7fa7a21c5bf8>
key        = 'randn'
match      = 'scipy\\.randn is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
_________________________ test_numpy_deprecation[rand] _________________________

key = 'rand'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = 2
dep        = None
func       = <function RandomState.rand at 0x7fa7a21c5b70>
key        = 'rand'
match      = 'scipy\\.rand is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
________________________ test_numpy_deprecation[array] _________________________

key = 'array'

    @pytest.mark.parametrize(
        'key', ('fft', 'ifft', 'diag', 'arccos',
                'randn', 'rand', 'array'))
    def test_numpy_deprecation(key):
        """Test that 'from numpy import *' functions are deprecated."""
        if key in ('fft', 'ifft', 'diag', 'arccos'):
            arg = [1.0, 0.]
        elif key == 'finfo':
            arg = float
        else:
            arg = 2
        func = getattr(scipy, key)
        if key == 'fft':
            match = r'scipy\.fft.*deprecated.*1.5.0.*'
        else:
            match = r'scipy\.%s is deprecated.*2\.0\.0' % key
        with deprecated_call(match=match) as dep:
            func(arg)  # deprecated
        # in case we catch more than one dep warning
>       fnames = [os.path.splitext(d.filename)[0] for d in dep.list]
E       AttributeError: 'NoneType' object has no attribute 'list'

arg        = 2
dep        = None
func       = <function array at 0x7fa7a218b268>
key        = 'array'
match      = 'scipy\\.array is deprecated.*2\\.0\\.0'

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/_lib/tests/test__util.py:143: AttributeError
____________________________ test_tolerance_float32 ____________________________

    @pytest.mark.xfail(platform.machine() == 'ppc64le',
                       reason="fails on ppc64le")
    def test_tolerance_float32():
        """Check lobpcg for attainable tolerance in float32.
        """
        np.random.seed(1234)
        n = 50
        m = 3
        vals = -np.arange(1, n + 1)
        A = diags([vals], [0], (n, n))
        A = A.astype(np.float32)
        X = np.random.randn(n, m)
        X = X.astype(np.float32)
        eigvals, _ = lobpcg(A, X, tol=1e-9, maxiter=50, verbosityLevel=0)
>       assert_allclose(eigvals, -np.arange(1, 1 + m), atol=1e-5)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=1e-05
E       
E       Mismatched elements: 1 / 3 (33.3%)
E       Max absolute difference: 0.01461172
E       Max relative difference: 0.00487057
E        x: array([-1.      , -1.999997, -3.014612], dtype=float32)
E        y: array([-1, -2, -3])

A          = <50x50 sparse matrix of type '<class 'numpy.float32'>'
	with 50 stored elements (1 diagonals) in DIAgonal format>
X          = array([[ 4.71435159e-01, -1.19097567e+00,  1.43270695e+00],
       [-3.12651902e-01, -7.20588744e-01,  8.87162924e-01]...241e+00, -5.24336100e-01,  7.00907707e-01],
       [ 9.84188080e-01, -1.21728405e-01,  2.36576867e+00]], dtype=float32)
_          = array([[-1.00000000e+00,  2.00615219e-12, -2.44451428e-08],
       [ 1.97884764e-12,  1.00000012e+00, -7.59038812e-07]...590e-08, -1.29014893e-07, -3.75821907e-03],
       [ 7.36326111e-09,  1.62651048e-08,  1.63773284e-03]], dtype=float32)
eigvals    = array([-1.       , -1.9999971, -3.0146117], dtype=float32)
m          = 3
n          = 50
vals       = array([ -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11, -12, -13,
       -14, -15, -16, -17, -18, -19, -20, -21,..., -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39,
       -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50])

.local/lib/python3.5/site-packages/scipy-1.4.1-py3.5-linux-x86_64.egg/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py:288: AssertionError
 8 failed, 19497 passed, 1310 skipped, 10954 deselected, 76 xfailed, 7 xpassed in 448.31 seconds 
False

Not sure if this is a problem.

python -3.5.2 on Ubuntu. scipy 1.4.1 installed from source (ran python3 setup.py from tarball) and numpy version 1.17.5

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

@j-bowhay that is a very tiny issue with test tolerances. What OS and Python install are you using?

This was under Python 3.10.4 on Linux (x86_64)

If you can fix the failure reliably with a small bump in the value of tol=1e-5 in the test, that is fine to do - a PR would be great in that case.

Will have a play and see