Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: numpy.test failure "FloatingPointError not raised by divmod" #27350

Open
AgilentGCMS opened this issue Sep 5, 2024 · 5 comments
Open

BUG: numpy.test failure "FloatingPointError not raised by divmod" #27350

AgilentGCMS opened this issue Sep 5, 2024 · 5 comments
Assignees
Labels

Comments

@AgilentGCMS
Copy link

AgilentGCMS commented Sep 5, 2024

Describe the issue:

I compiled numpy from source with intel oneapi 2024.2. It built fine, but when executing numpy.test() there is one failure. I compiled numpy with

CC=icx CXX=icpx FC=ifx CFLAGS='-fveclib=none -fp-model=strict -fPIC -xHost' FFLAGS='-fp-model=strict -fPIC -xHost' CXXFLAGS='-fp-model=strict -fPIC -xHost' python -m pip install --no-build-isolation -v . -Cbuild-dir=build -Csetup-args=-Dallow-noblas=false -Csetup-args=-Dblas-order=mkl -Csetup-args=-Dlapack-order=mkl -Csetup-args=-Dblas=mkl-dynamic-lp64-iomp -Csetup-args=-Dlapack=mkl-dynamic-lp64-iomp

i.e., I did ask for strict floating point, otherwise fast math can cause issues with numpy.

Reproduce the code example:

python -c 'import numpy; numpy.test()'

Error message:

===================================================================================== FAILURES =====================================================================================
____________________________________________________________________ TestRemainder.test_float_divmod_errors[d] _____________________________________________________________________

self = <numpy._core.tests.test_umath.TestRemainder object at 0x7fc6be77ed10>, dtype = 'd'

    @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
    @pytest.mark.xfail(sys.platform.startswith("darwin"),
            reason="MacOS seems to not give the correct 'invalid' warning for "
                   "`fmod`.  Hopefully, others always do.")
    @pytest.mark.parametrize('dtype', np.typecodes['Float'])
    def test_float_divmod_errors(self, dtype):
        # Check valid errors raised for divmod and remainder
        fzero = np.array(0.0, dtype=dtype)
        fone = np.array(1.0, dtype=dtype)
        finf = np.array(np.inf, dtype=dtype)
        fnan = np.array(np.nan, dtype=dtype)
        # since divmod is combination of both remainder and divide
        # ops it will set both dividebyzero and invalid flags
        with np.errstate(divide='raise', invalid='ignore'):
            assert_raises(FloatingPointError, np.divmod, fone, fzero)
        with np.errstate(divide='ignore', invalid='raise'):
            assert_raises(FloatingPointError, np.divmod, fone, fzero)
        with np.errstate(invalid='raise'):
            assert_raises(FloatingPointError, np.divmod, fzero, fzero)
        with np.errstate(invalid='raise'):
>           assert_raises(FloatingPointError, np.divmod, finf, finf)

dtype      = 'd'
finf       = array(inf)
fnan       = array(nan)
fone       = array(1.)
fzero      = array(0.)
self       = <numpy._core.tests.test_umath.TestRemainder object at 0x7fc6be77ed10>

../../packages/lib/python3.11/site-packages/numpy/_core/tests/test_umath.py:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../packages/lib/python3.11/unittest/case.py:766: in assertRaises
    return context.handle('assertRaises', args, kwargs)
        args       = (<ufunc 'divmod'>, array(inf), array(inf))
        context    = None
        expected_exception = <class 'FloatingPointError'>
        kwargs     = {}
        self       = <numpy.testing._private.utils._Dummy testMethod=nop>
../../packages/lib/python3.11/unittest/case.py:236: in handle
    with self:
        args       = [array(inf), array(inf)]
        callable_obj = <ufunc 'divmod'>
        kwargs     = {}
        name       = 'assertRaises'
        self       = None
../../packages/lib/python3.11/unittest/case.py:259: in __exit__
    self._raiseFailure("{} not raised by {}".format(exc_name,
        exc_name   = 'FloatingPointError'
        exc_type   = None
        exc_value  = None
        self       = <unittest.case._AssertRaisesContext object at 0x7fc678cfdd90>
        tb         = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.case._AssertRaisesContext object at 0x7fc678cfdd90>, standardMsg = 'FloatingPointError not raised by divmod'

    def _raiseFailure(self, standardMsg):
        msg = self.test_case._formatMessage(self.msg, standardMsg)
>       raise self.test_case.failureException(msg)
E       AssertionError: FloatingPointError not raised by divmod

msg        = 'FloatingPointError not raised by divmod'
self       = <unittest.case._AssertRaisesContext object at 0x7fc678cfdd90>
standardMsg = 'FloatingPointError not raised by divmod'

../../packages/lib/python3.11/unittest/case.py:199: AssertionError

Python and NumPy Versions:

2.0.1
3.11.9 (main, Sep 4 2024, 23:36:12) [Clang 19.0.0 (icx 2024.2.1.20240711)]

Runtime Environment:

[{'numpy_version': '2.0.1',
'python': '3.11.9 (main, Sep 4 2024, 23:36:12) [Clang 19.0.0 (icx '
'2024.2.1.20240711)]',
'uname': uname_result(system='Linux', node='gs6101-trident.ndc.nasa.gov', release='4.18.0-553.16.1.el8_10.x86_64', version='#1 SMP Thu Aug 1 04:16:12 EDT 2024', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX'],
'not_found': ['AVX512_KNL',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'filepath': '/ford1/local/intel/oneapi-2024.2/compiler/2024.2/lib/libiomp5.so',
'internal_api': 'openmp',
'num_threads': 8,
'prefix': 'libiomp',
'user_api': 'openmp',
'version': None}]

Context for the issue:

No response

@mattip
Copy link
Member

mattip commented Sep 5, 2024

cc @r-devulap

@github-staff github-staff deleted a comment from AgilentGCMS Sep 5, 2024
@r-devulap r-devulap self-assigned this Sep 5, 2024
@r-devulap
Copy link
Member

will take a look.

@azeem30
Copy link

azeem30 commented Sep 6, 2024

is this solved?

@AgilentGCMS
Copy link
Author

is this solved?

Not yet

@AgilentGCMS
Copy link
Author

FYI this error is still there in numpy-2.1.1.

===================================================================================== FAILURES =====================================================================================
____________________________________________________________________ TestRemainder.test_float_divmod_errors[d] _____________________________________________________________________

self = <test_umath.TestRemainder object at 0x7f8f6ca49250>, dtype = 'd'

    @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
    @pytest.mark.xfail(sys.platform.startswith("darwin"),
            reason="MacOS seems to not give the correct 'invalid' warning for "
                   "`fmod`.  Hopefully, others always do.")
    @pytest.mark.parametrize('dtype', np.typecodes['Float'])
    def test_float_divmod_errors(self, dtype):
        # Check valid errors raised for divmod and remainder
        fzero = np.array(0.0, dtype=dtype)
        fone = np.array(1.0, dtype=dtype)
        finf = np.array(np.inf, dtype=dtype)
        fnan = np.array(np.nan, dtype=dtype)
        # since divmod is combination of both remainder and divide
        # ops it will set both dividebyzero and invalid flags
        with np.errstate(divide='raise', invalid='ignore'):
            assert_raises(FloatingPointError, np.divmod, fone, fzero)
        with np.errstate(divide='ignore', invalid='raise'):
            assert_raises(FloatingPointError, np.divmod, fone, fzero)
        with np.errstate(invalid='raise'):
            assert_raises(FloatingPointError, np.divmod, fzero, fzero)
        with np.errstate(invalid='raise'):
>           assert_raises(FloatingPointError, np.divmod, finf, finf)

dtype      = 'd'
finf       = array(inf)
fnan       = array(nan)
fone       = array(1.)
fzero      = array(0.)
self       = <test_umath.TestRemainder object at 0x7f8f6ca49250>

../../packages/lib/python3.11/site-packages/numpy/_core/tests/test_umath.py:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../packages/lib/python3.11/unittest/case.py:766: in assertRaises
    return context.handle('assertRaises', args, kwargs)
        args       = (<ufunc 'divmod'>, array(inf), array(inf))
        context    = None
        expected_exception = <class 'FloatingPointError'>
        kwargs     = {}
        self       = <numpy.testing._private.utils._Dummy testMethod=nop>
../../packages/lib/python3.11/unittest/case.py:236: in handle
    with self:
        args       = [array(inf), array(inf)]
        callable_obj = <ufunc 'divmod'>
        kwargs     = {}
        name       = 'assertRaises'
        self       = None
../../packages/lib/python3.11/unittest/case.py:259: in __exit__
    self._raiseFailure("{} not raised by {}".format(exc_name,
        exc_name   = 'FloatingPointError'
        exc_type   = None
        exc_value  = None
        self       = <unittest.case._AssertRaisesContext object at 0x7f8f30723c50>
        tb         = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.case._AssertRaisesContext object at 0x7f8f30723c50>, standardMsg = 'FloatingPointError not raised by divmod'

    def _raiseFailure(self, standardMsg):
        msg = self.test_case._formatMessage(self.msg, standardMsg)
>       raise self.test_case.failureException(msg)
E       AssertionError: FloatingPointError not raised by divmod

msg        = 'FloatingPointError not raised by divmod'
self       = <unittest.case._AssertRaisesContext object at 0x7f8f30723c50>
standardMsg = 'FloatingPointError not raised by divmod'

../../packages/lib/python3.11/unittest/case.py:199: AssertionError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants
@mattip @AgilentGCMS @r-devulap @azeem30 and others