Skip to content

Instantly share code, notes, and snippets.

@isuruf
Last active September 24, 2024 22:12
Show Gist options
  • Save isuruf/aaead06e2b1d801a20910bc44a9ffcdf to your computer and use it in GitHub Desktop.
Save isuruf/aaead06e2b1d801a20910bc44a9ffcdf to your computer and use it in GitHub Desktop.
Use conda-forge lapack with acelerate as blas backend
git clone https://github.com/isuruf/vecLibFort
cd vecLibFort
conda create -n numpy pytest hypothesis numpy "libblas=*=*netlib" --yes
conda activate numpy
clang -O3 -c -o vecLibFort.o vecLibFort.c
clang -shared -o libblas.3.dylib vecLibFort.o -Wl,-reexport_library,$(xcrun -show-sdk-path)/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.tbd
codesign -s - -f libblas.3.dylib
rm $CONDA_PREFIX/lib/libblas.3.dylib
rm $CONDA_PREFIX/lib/libcblas.3.dylib
cp libblas.3.dylib $CONDA_PREFIX/lib/libblas.3.dylib
cp libblas.3.dylib $CONDA_PREFIX/lib/libcblas.3.dylib
python -c "import numpy; numpy.test()"
@ogrisel
Copy link

ogrisel commented Jan 31, 2021

Ok the f2py crash went away with the compilers package. I get now get 6 failures. Here is the full report:

========================================================================= FAILURES ==========================================================================
___________________________________________ TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full[reciprocal] ____________________________________________

self = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at 0x113c22220>, 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: divide by zero 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 0x113c22220>
ufunc      = <ufunc 'reciprocal'>
val        = 0.7853981633974483

miniforge3/envs/numpy/lib/python3.9/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 0x113c22220>, 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)):
>                   ufunc(obj_arr)

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 0x113c22220>
ufunc      = <ufunc 'reciprocal'>
val        = 0.7853981633974483

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_ufunc.py:175: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
miniforge3/envs/numpy/lib/python3.9/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 0x113c31c10>
        tb         = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.case._AssertRaisesContext object at 0x113c31c10>, 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 0x113c31c10>
standardMsg = 'FloatingPointError not raised'

miniforge3/envs/numpy/lib/python3.9/unittest/case.py:163: AssertionError
____________________________________________________ TestSharedMemory.test_in_from_2casttype[LONGDOUBLE] ____________________________________________________

self = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124a41e80>

    def test_in_from_2casttype(self):
        for t in self.type.cast_types():
            obj = array(self.num2seq, dtype=t.dtype)
>           a = self.array([len(self.num2seq)], intent.in_, obj)

a          = <numpy.f2py.tests.test_array_from_pyobj.Array object at 0x124a561c0>
obj        = array([1, 2])
self       = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124a41e80>
t          = <numpy.f2py.tests.test_array_from_pyobj.Type object at 0x124899d30>

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py:322: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py:313: in <lambda>
    Array(Type(request.param), dims, intent, obj)
        dims       = [2]
        intent     = Intent(['in'])
        obj        = array([1, 2])
        request    = <SubRequest 'setup_type' for <Function test_in_from_2seq[LONGDOUBLE]>>
        self       = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124a41e80>
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <numpy.f2py.tests.test_array_from_pyobj.Array object at 0x124a56250>, typ = <numpy.f2py.tests.test_array_from_pyobj.Type object at 0x124899fd0>
dims = [2], intent = Intent(['in']), obj = array([1, 2])

    def __init__(self, typ, dims, intent, obj):
        self.type = typ
        self.dims = dims
        self.intent = intent
        self.obj_copy = copy.deepcopy(obj)
        self.obj = obj
    
        # arr.dtypechar may be different from typ.dtypechar
        self.arr = wrap.call(typ.type_num, dims, intent.flags, obj)
    
        assert_(isinstance(self.arr, ndarray), repr(type(self.arr)))
    
        self.arr_attr = wrap.array_attrs(self.arr)
    
        if len(dims) > 1:
            if self.intent.is_intent('c'):
                assert_(intent.flags & wrap.F2PY_INTENT_C)
                assert_(not self.arr.flags['FORTRAN'],
                        repr((self.arr.flags, getattr(obj, 'flags', None))))
                assert_(self.arr.flags['CONTIGUOUS'])
                assert_(not self.arr_attr[6] & wrap.FORTRAN)
            else:
                assert_(not intent.flags & wrap.F2PY_INTENT_C)
                assert_(self.arr.flags['FORTRAN'])
                assert_(not self.arr.flags['CONTIGUOUS'])
                assert_(self.arr_attr[6] & wrap.FORTRAN)
    
        if obj is None:
            self.pyarr = None
            self.pyarr_attr = None
            return
    
        if intent.is_intent('cache'):
            assert_(isinstance(obj, ndarray), repr(type(obj)))
            self.pyarr = array(obj).reshape(*dims).copy()
        else:
            self.pyarr = array(array(obj, dtype=typ.dtypechar).reshape(*dims),
                               order=self.intent.is_intent('c') and 'C' or 'F')
            assert_(self.pyarr.dtype == typ,
                    repr((self.pyarr.dtype, typ)))
        assert_(self.pyarr.flags['OWNDATA'], (obj, intent))
        self.pyarr_attr = wrap.array_attrs(self.pyarr)
    
        if len(dims) > 1:
            if self.intent.is_intent('c'):
                assert_(not self.pyarr.flags['FORTRAN'])
                assert_(self.pyarr.flags['CONTIGUOUS'])
                assert_(not self.pyarr_attr[6] & wrap.FORTRAN)
            else:
                assert_(self.pyarr.flags['FORTRAN'])
                assert_(not self.pyarr.flags['CONTIGUOUS'])
                assert_(self.pyarr_attr[6] & wrap.FORTRAN)
    
        assert_(self.arr_attr[1] == self.pyarr_attr[1])  # nd
        assert_(self.arr_attr[2] == self.pyarr_attr[2])  # dimensions
        if self.arr_attr[1] <= 1:
            assert_(self.arr_attr[3] == self.pyarr_attr[3],
                    repr((self.arr_attr[3], self.pyarr_attr[3],
                          self.arr.tobytes(), self.pyarr.tobytes())))  # strides
        assert_(self.arr_attr[5][-2:] == self.pyarr_attr[5][-2:],
                repr((self.arr_attr[5], self.pyarr_attr[5])))  # descr
        assert_(self.arr_attr[6] == self.pyarr_attr[6],
                repr((self.arr_attr[6], self.pyarr_attr[6],
                      flags2names(0 * self.arr_attr[6] - self.pyarr_attr[6]),
                      flags2names(self.arr_attr[6]), intent)))  # flags
    
        if intent.is_intent('cache'):
            assert_(self.arr_attr[5][3] >= self.type.elsize,
                    repr((self.arr_attr[5][3], self.type.elsize)))
        else:
            assert_(self.arr_attr[5][3] == self.type.elsize,
                    repr((self.arr_attr[5][3], self.type.elsize)))
        assert_(self.arr_equal(self.pyarr, self.arr))
    
        if isinstance(self.obj, ndarray):
            if typ.elsize == Type(obj.dtype).elsize:
                if not intent.is_intent('copy') and self.arr_attr[1] <= 1:
>                   assert_(self.has_shared_memory())
E                   AssertionError

dims       = [2]
intent     = Intent(['in'])
obj        = array([1, 2])
self       = <numpy.f2py.tests.test_array_from_pyobj.Array object at 0x124a56250>
typ        = <numpy.f2py.tests.test_array_from_pyobj.Type object at 0x124899fd0>

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py:272: AssertionError
__________________________________________________ TestSharedMemory.test_f_in_from_23casttype[LONGDOUBLE] ___________________________________________________

self = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124b63910>

    def test_f_in_from_23casttype(self):
        for t in self.type.cast_types():
            obj = array(self.num23seq, dtype=t.dtype, order='F')
            a = self.array([len(self.num23seq), len(self.num23seq[0])],
                           intent.in_, obj)
            if t.elsize == self.type.elsize:
>               assert_(a.has_shared_memory(), repr(t.dtype))
E               AssertionError: <class 'numpy.int64'>

a          = <numpy.f2py.tests.test_array_from_pyobj.Array object at 0x124a56f70>
obj        = array([[1, 2, 3],
       [4, 5, 6]])
self       = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124b63910>
t          = <numpy.f2py.tests.test_array_from_pyobj.Type object at 0x124899d30>

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py:391: AssertionError
__________________________________________________ TestSharedMemory.test_c_in_from_23casttype[LONGDOUBLE] ___________________________________________________

self = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124a74610>

    def test_c_in_from_23casttype(self):
        for t in self.type.cast_types():
            obj = array(self.num23seq, dtype=t.dtype)
            a = self.array([len(self.num23seq), len(self.num23seq[0])],
                           intent.in_.c, obj)
            if t.elsize == self.type.elsize:
>               assert_(a.has_shared_memory(), repr(t.dtype))
E               AssertionError: <class 'numpy.int64'>

a          = <numpy.f2py.tests.test_array_from_pyobj.Array object at 0x124a746d0>
obj        = array([[1, 2, 3],
       [4, 5, 6]])
self       = <numpy.f2py.tests.test_array_from_pyobj.TestSharedMemory object at 0x124a74610>
t          = <numpy.f2py.tests.test_array_from_pyobj.Type object at 0x124899d30>

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py:401: AssertionError
_________________________________________ TestMaskedArrayInPlaceArithmetics.test_inplace_floor_division_scalar_type _________________________________________

self = <numpy.ma.tests.test_core.TestMaskedArrayInPlaceArithmetics object at 0x154daf310>

    def test_inplace_floor_division_scalar_type(self):
        # Test of inplace division
        for t in self.othertypes:
            with warnings.catch_warnings(record=True) as w:
                warnings.filterwarnings("always")
                (x, y, xm) = (_.astype(t) for _ in self.uint8data)
                x = arange(10, dtype=t) * t(2)
                xm = arange(10, dtype=t) * t(2)
                xm[2] = masked
                x //= t(2)
                xm //= t(2)
                assert_equal(x, y)
                assert_equal(xm, y)
    
>               assert_equal(len(w), 0, "Failed on type=%s." % t)

self       = <numpy.ma.tests.test_core.TestMaskedArrayInPlaceArithmetics object at 0x154daf310>
t          = <class 'numpy.complex64'>
w          = [<warnings.WarningMessage object at 0x154daf670>, <warnings.WarningMessage object at 0x154daf6a0>, <warnings.WarningMessage object at 0x154daf6d0>, <warnings.WarningMessage object at 0x154daf700>]
x          = masked_array(data=[0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j, 6.+0.j,
                   7.+0.j, 8.+0.j, 9.+0.j],
             mask=False,
       fill_value=(1e+20+0j),
            dtype=complex64)
xm         = masked_array(data=[0j, (1+0j), --, (3+0j), (4+0j), (5+0j), (6+0j), (7+0j),
                   (8+0j), (9+0j)],
       ...alse, False, False, False,
                   False, False],
       fill_value=(1e+20+0j),
            dtype=complex64)
y          = masked_array(data=[0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j, 6.+0.j,
                   7.+0.j, 8.+0.j, 9.+0.j],
             mask=False,
       fill_value=(1e+20+0j),
            dtype=complex64)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/tests/test_core.py:2848: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

actual = 4, desired = 0, err_msg = "Failed on type=<class 'numpy.complex64'>."

    def assert_equal(actual, desired, err_msg=''):
        """
        Asserts that two items are equal.
    
        """
        # Case #1: dictionary .....
        if isinstance(desired, dict):
            if not isinstance(actual, dict):
                raise AssertionError(repr(type(actual)))
            assert_equal(len(actual), len(desired), err_msg)
            for k, i in desired.items():
                if k not in actual:
                    raise AssertionError(f"{k} not in {actual}")
                assert_equal(actual[k], desired[k], f'key={k!r}\n{err_msg}')
            return
        # Case #2: lists .....
        if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)):
            return _assert_equal_on_sequences(actual, desired, err_msg='')
        if not (isinstance(actual, ndarray) or isinstance(desired, ndarray)):
            msg = build_err_msg([actual, desired], err_msg,)
            if not desired == actual:
>               raise AssertionError(msg)
E               AssertionError: 
E               Items are not equal: Failed on type=<class 'numpy.complex64'>.
E                ACTUAL: 4
E                DESIRED: 0

actual     = 4
desired    = 0
err_msg    = "Failed on type=<class 'numpy.complex64'>."
msg        = "\nItems are not equal: Failed on type=<class 'numpy.complex64'>.\n ACTUAL: 4\n DESIRED: 0"

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/testutils.py:129: AssertionError
_________________________________________ TestMaskedArrayInPlaceArithmetics.test_inplace_floor_division_array_type __________________________________________

self = <numpy.ma.tests.test_core.TestMaskedArrayInPlaceArithmetics object at 0x154daf5b0>

    def test_inplace_floor_division_array_type(self):
        # Test of inplace division
        for t in self.othertypes:
            with warnings.catch_warnings(record=True) as w:
                warnings.filterwarnings("always")
                (x, y, xm) = (_.astype(t) for _ in self.uint8data)
                m = xm.mask
                a = arange(10, dtype=t)
                a[-1] = masked
                x //= a
                xm //= a
                assert_equal(x, y // a)
                assert_equal(xm, y // a)
                assert_equal(
                    xm.mask,
                    mask_or(mask_or(m, a.mask), (a == t(0)))
                )
    
>               assert_equal(len(w), 0, f'Failed on type={t}.')

a          = masked_array(data=[0j, (1+0j), (2+0j), (3+0j), (4+0j), (5+0j), (6+0j),
                   (7+0j), (8+0j), --],
       ...alse, False, False, False,
                   False,  True],
       fill_value=(1e+20+0j),
            dtype=complex64)
m          = array([ True, False,  True, False, False, False, False, False, False,
        True])
self       = <numpy.ma.tests.test_core.TestMaskedArrayInPlaceArithmetics object at 0x154daf5b0>
t          = <class 'numpy.complex64'>
w          = [<warnings.WarningMessage object at 0x154daf9d0>, <warnings.WarningMessage object at 0x154daf970>, <warnings.WarningMessage object at 0x154daf850>, <warnings.WarningMessage object at 0x154daf8e0>]
x          = masked_array(data=[--, (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j),
                   (1+0j), (1+0j), --],
       ...alse, False, False, False,
                   False,  True],
       fill_value=(1e+20+0j),
            dtype=complex64)
xm         = masked_array(data=[--, (1+0j), --, (1+0j), (1+0j), (1+0j), (1+0j), (1+0j),
                   (1+0j), --],
           ...alse, False, False, False,
                   False,  True],
       fill_value=(1e+20+0j),
            dtype=complex64)
y          = masked_array(data=[0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j, 6.+0.j,
                   7.+0.j, 8.+0.j, 9.+0.j],
             mask=False,
       fill_value=(1e+20+0j),
            dtype=complex64)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/tests/test_core.py:2868: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

actual = 4, desired = 0, err_msg = "Failed on type=<class 'numpy.complex64'>."

    def assert_equal(actual, desired, err_msg=''):
        """
        Asserts that two items are equal.
    
        """
        # Case #1: dictionary .....
        if isinstance(desired, dict):
            if not isinstance(actual, dict):
                raise AssertionError(repr(type(actual)))
            assert_equal(len(actual), len(desired), err_msg)
            for k, i in desired.items():
                if k not in actual:
                    raise AssertionError(f"{k} not in {actual}")
                assert_equal(actual[k], desired[k], f'key={k!r}\n{err_msg}')
            return
        # Case #2: lists .....
        if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)):
            return _assert_equal_on_sequences(actual, desired, err_msg='')
        if not (isinstance(actual, ndarray) or isinstance(desired, ndarray)):
            msg = build_err_msg([actual, desired], err_msg,)
            if not desired == actual:
>               raise AssertionError(msg)
E               AssertionError: 
E               Items are not equal: Failed on type=<class 'numpy.complex64'>.
E                ACTUAL: 4
E                DESIRED: 0

actual     = 4
desired    = 0
err_msg    = "Failed on type=<class 'numpy.complex64'>."
msg        = "\nItems are not equal: Failed on type=<class 'numpy.complex64'>.\n ACTUAL: 4\n DESIRED: 0"

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/testutils.py:129: AssertionError
===================================================================== warnings summary ======================================================================
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_scalarmath.py::TestBaseMath::test_blocked
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_scalarmath.py:88: RuntimeWarning: divide by zero encountered in reciprocal
    assert_almost_equal(np.reciprocal(inp2),

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestDivision::test_floor_division_complex
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:286: RuntimeWarning: divide by zero encountered in floor_divide
    y = np.floor_divide(x**2, x)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestPower::test_power_float
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:558: RuntimeWarning: divide by zero encountered in reciprocal
    assert_almost_equal(x**(-1), [1., 0.5, 1./3])

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1006: RuntimeWarning: divide by zero encountered in reciprocal
    y_true128 = myfunc(x_f128)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1013: RuntimeWarning: divide by zero encountered in reciprocal
    assert_array_max_ulp(myfunc(x_f64), np.float64(y_true128),

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1020: RuntimeWarning: divide by zero encountered in reciprocal
    assert_equal(myfunc(x_f64[::jj]), y_true64[::jj])

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1011: RuntimeWarning: divide by zero encountered in reciprocal
    assert_array_max_ulp(myfunc(x_f32), np.float32(y_true128),

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1017: RuntimeWarning: divide by zero encountered in reciprocal
    y_true32 = myfunc(x_f32)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1018: RuntimeWarning: divide by zero encountered in reciprocal
    y_true64 = myfunc(x_f64)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:1021: RuntimeWarning: divide by zero encountered in reciprocal
    assert_equal(myfunc(x_f32[::jj]), y_true32[::jj])

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormDouble::test_axis
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormSingle::test_axis
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormInt64::test_axis
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/linalg.py:2569: RuntimeWarning: divide by zero encountered in reciprocal
    ret **= (1 / ord)

miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormDouble::test_axis
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormSingle::test_axis
miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/tests/test_linalg.py::TestNormInt64::test_axis
  /Users/ogrisel/miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/linalg/linalg.py:2567: RuntimeWarning: divide by zero encountered in reciprocal
    absx **= ord

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================================================================== short test summary info ==================================================================
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/core/tests/test_ufunc.py::TestUfuncGenericLoops::test_unary_PyUFunc_O_O_method_full[reciprocal]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_in_from_2casttype[LONGDOUBLE]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_f_in_from_23casttype[LONGDOUBLE]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_c_in_from_23casttype[LONGDOUBLE]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_scalar_type
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_array_type
6 failed, 12290 passed, 96 skipped, 1205 deselected, 19 xfailed, 3 xpassed, 16 warnings in 93.99s (0:01:33)

@ogrisel
Copy link

ogrisel commented Jan 31, 2021

If you use the openblas build, tests work?

Running the numpy test on the same machine in an openblas env, I get:

10 failed, 11836 passed, 102 skipped, 1205 deselected, 19 xfailed, 3 xpassed, 24 warnings, 444 errors in 86.37s (0:01:26)

the log is even more verbose. Here is the full log:

https://gist.github.com/ogrisel/be1fd7f9d00f32f3c702a10a9886239d

The 10 failures are:

FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/core/tests/test_ufunc.py::TestUfuncGenericLoops::test_unary_PyUFunc_O_O_method_full[reciprocal]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/distutils/tests/test_system_info.py::TestSystemInfoReading::test_compile1
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/distutils/tests/test_system_info.py::TestSystemInfoReading::test_compile2
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_compile_function.py::test_f2py_init_compile[extra_args0]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_compile_function.py::test_f2py_init_compile[--noopt --debug]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_compile_function.py::test_f2py_init_compile[]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_compile_function.py::test_compile_from_strings[program test_f2py\nend program test_f2py0]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_compile_function.py::test_compile_from_strings[program test_f2py\nend program test_f2py1]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_scalar_type
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_array_type

@ogrisel
Copy link

ogrisel commented Jan 31, 2021

So the tests that only fail in the Accelerate env are:

FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_in_from_2casttype[LONGDOUBLE]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_f_in_from_23casttype[LONGDOUBLE]
FAILED miniforge3/envs/numpy/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_c_in_from_23casttype[LONGDOUBLE]

@isuruf
Copy link
Author

isuruf commented Jan 31, 2021

Running the numpy test on the same machine in an openblas env, I get:

You probably need to install compilers there too.

@ogrisel
Copy link

ogrisel commented Jan 31, 2021

I did install the compilers in that env (prior to running the numpy tests):

% conda list compilers
# packages in environment at /Users/ogrisel/miniforge3/envs/sklearn-0241:
#
# Name                    Version                   Build  Channel
compilers                 1.1.3                hce30654_0    conda-forge

@isuruf
Copy link
Author

isuruf commented Jan 31, 2021

/Users/ogrisel/miniforge3/envs/sklearn-0241/include/python3.9/Python.h:25:10: fatal error: 'stdio.h' file not found
E #include <stdio.h>

above error is because the env is not activated. (If it is activated, then $SDKROOT env variable should be set to the SDK dir)

@ogrisel
Copy link

ogrisel commented Feb 1, 2021

You are right, something was off with this env. I deactivated everything and reactivated and now I get:

=========================== short test summary info ============================
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/core/tests/test_ufunc.py::TestUfuncGenericLoops::test_unary_PyUFunc_O_O_method_full[reciprocal]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_in_from_2casttype[LONGDOUBLE]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_f_in_from_23casttype[LONGDOUBLE]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_c_in_from_23casttype[LONGDOUBLE]
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_scalar_type
FAILED miniforge3/envs/sklearn-0241/lib/python3.9/site-packages/numpy/ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_array_type
6 failed, 12284 passed, 102 skipped, 1205 deselected, 19 xfailed, 3 xpassed, 24 warnings in 87.73s (0:01:27)

which are the same failures as with the Accelerate BLAS + netlib LAPACK combo so probably unrelated to BLAS and LAPACK.

@ogrisel
Copy link

ogrisel commented Feb 1, 2021

@ogrisel
Copy link

ogrisel commented Feb 1, 2021

I noticed that I had two nested conda env in the previous run (the sklearn-0241 env nested under my dev env). Maybe that was the cause of the problem...

@ogrisel
Copy link

ogrisel commented Feb 1, 2021

Or maybe I installed compilers in sklearn-0241 after the creation and activation of sklearn-0241 without reactivating it. I cannot remember.

@kirksw
Copy link

kirksw commented May 3, 2021

I get AssertionErrors from multiple important routines using this on my M1 mac. However from what I have been reading numpy and scipy blocked the accelerate backend due to numerical issues.

=============================== short test summary info ================================ FAILED core/tests/test_ufunc.py::TestUfuncGenericLoops::test_unary_PyUFunc_O_O_method_full[reciprocal] FAILED f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_in_from_2casttype[LONGDOUBLE] FAILED f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_f_in_from_23casttype[LONGDOUBLE] FAILED f2py/tests/test_array_from_pyobj.py::TestSharedMemory::test_c_in_from_23casttype[LONGDOUBLE] FAILED linalg/tests/test_linalg.py::TestSVDHermitian::test_herm_cases - AssertionErro... FAILED linalg/tests/test_linalg.py::TestPinvHermitian::test_herm_cases - AssertionErr... FAILED linalg/tests/test_linalg.py::TestEighCases::test_herm_cases - AssertionError: ... FAILED linalg/tests/test_linalg.py::TestCholesky::test_basic_property - numpy.linalg.... FAILED ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_scalar_type FAILED ma/tests/test_core.py::TestMaskedArrayInPlaceArithmetics::test_inplace_floor_division_array_type 10 failed, 12457 passed, 103 skipped, 1208 deselected, 19 xfailed, 3 xpassed, 16 warnings in 98.77s (0:01:38)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment