Skip to content

BUG: missing exception in test_unary_PyUFunc_O_O_method_full[reciprocal] on osx with 1.21.5 #20637

@h-vetinari

Description

@h-vetinari

Building 1.21.5 for conda-forge, there was the following error on osx:

=================================== FAILURES ===================================
_____ TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full[reciprocal] _____

self = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at 0x11037da50>
ufunc = <ufunc 'reciprocal'>

    @pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS)
    def test_unary_PyUFunc_O_O_method_full(self, ufunc):
        """Compare the result of the object loop with non-object one"""
        val = np.float64(np.pi/4)

        class MyFloat(np.float64):
            def __getattr__(self, attr):
                try:
                    return super().__getattr__(attr)
                except AttributeError:
                    return lambda: getattr(np.core.umath, attr)(val)

        num_arr = np.array([val], dtype=np.float64)
        obj_arr = np.array([MyFloat(val)], dtype="O")

        with np.errstate(all="raise"):
            try:
>               res_num = ufunc(num_arr)
E               FloatingPointError: invalid value encountered in reciprocal

MyFloat    = <class 'numpy.core.tests.test_ufunc.TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full.<locals>.MyFloat'>
num_arr    = array([0.78539816])
obj_arr    = array([0.7853981633974483], dtype=object)
self       = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at 0x11037da50>
ufunc      = <ufunc 'reciprocal'>
val        = 0.7853981633974483

../[...]/lib/python3.10/site-packages/numpy/core/tests/test_ufunc.py:172: FloatingPointError

During handling of the above exception, another exception occurred:

self = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at 0x11037da50>
ufunc = <ufunc 'reciprocal'>

    @pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS)
    def test_unary_PyUFunc_O_O_method_full(self, ufunc):
        """Compare the result of the object loop with non-object one"""
        val = np.float64(np.pi/4)

        class MyFloat(np.float64):
            def __getattr__(self, attr):
                try:
                    return super().__getattr__(attr)
                except AttributeError:
                    return lambda: getattr(np.core.umath, attr)(val)

        num_arr = np.array([val], dtype=np.float64)
        obj_arr = np.array([MyFloat(val)], dtype="O")

        with np.errstate(all="raise"):
            try:
                res_num = ufunc(num_arr)
            except Exception as exc:
>               with assert_raises(type(exc)):

MyFloat    = <class 'numpy.core.tests.test_ufunc.TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full.<locals>.MyFloat'>
num_arr    = array([0.78539816])
obj_arr    = array([0.7853981633974483], dtype=object)
self       = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at 0x11037da50>
ufunc      = <ufunc 'reciprocal'>
val        = 0.7853981633974483

../[...]/lib/python3.10/site-packages/numpy/core/tests/test_ufunc.py:174:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../[...]/lib/python3.10/unittest/case.py:226: in __exit__
    self._raiseFailure("{} not raised".format(exc_name))
        exc_name   = 'FloatingPointError'
        exc_type   = None
        exc_value  = None
        self       = <unittest.case._AssertRaisesContext object at 0x11037ddb0>
        tb         = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.case._AssertRaisesContext object at 0x11037ddb0>
standardMsg = 'FloatingPointError not raised'

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

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

../[...]/lib/python3.10/unittest/case.py:163: AssertionError

I skipped it for the time being, but wanted to raise this issue. I also verified in conda-forge/numpy-feedstock#237 that it is (unlike some recent scipy failures) not dependent on the blas flavour being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions