Skip to content

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

@omarsoufiane

Description

@omarsoufiane

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions