Repository: scipy/scipy
File: scipy/stats/tests/test_axis_nan_policy.py (Python)

Code before:
# functions in stats._util.

from itertools import product, combinations_with_replacement, permutations
import os
import re
import pickle
import pytest
import warnings

import numpy as np
from numpy.testing import assert_allclose, assert_equal
from scipy import stats, special
from scipy.stats._axis_nan_policy import (_masked_arrays_2_sentinel_arrays,
                                          SmallSampleWarning,
                                          too_small_nd_omit, too_small_nd_not_omit,
                                          too_small_1d_omit, too_small_1d_not_omit)
from scipy._lib._util import AxisError
from scipy.conftest import skip_xp_invalid_arg


SCIPY_XSLOW = int(os.environ.get('SCIPY_XSLOW', '0'))


def _using_accelerate():
    config = np.show_config('dicts')
    return config['Build Dependencies']['blas']['name'] == 'Accelerate'


def unpack_ttest_result(res):
    low, high = res.confidence_interval()
    return (res.statistic, res.pvalue, res.df, res._standard_error,
            res._estimate, low, high)


def _get_ttest_ci(ttest):
    # get a function that returns the CI bounds of provided `ttest`
    def ttest_ci(*args, **kwargs):
        res = ttest(*args, **kwargs)
        return res.confidence_interval()
    return ttest_ci


def xp_mean_1samp(*args, **kwargs):
    kwargs.pop('_no_deco', None)
    return stats._stats_py._xp_mean(*args, **kwargs)


def xp_mean_2samp(*args, **kwargs):
    kwargs.pop('_no_deco', None)
    weights = args[1]
    return stats._stats_py._xp_mean(args[0], *args[2:], weights=weights, **kwargs)

Review comment (bug):
I checked locally on ARM Mac -- you're almost there -- just need switch from capital to lower case "A," this correctly fails for your test case locally:

```diff
--- a/scipy/stats/tests/test_axis_nan_policy.py
+++ b/scipy/stats/tests/test_axis_nan_policy.py
@@ -27,7 +27,7 @@ SCIPY_XSLOW = int(os.environ.get('SCIPY_XSLOW', '0'))
 
 def _using_accelerate():
     config = np.show_config('dicts')
-    return config['Build Dependencies']['blas']['name'] == 'Accelerate'
+    return config['Build Dependencies']['blas']['name'] == 'accelerate'
```

I suppose if you're aiming to build up robust long-term infrastructure for probing this, you might want to just `lower()` the result for string comparison as well.

If you need to specifically also detect x86_64 vs. ARM for Mac (based on the current CI situation), that is of course straightforward business in the Python standard library.

And to confirm, it is the *NumPy* linear algebra backend you care about, not the SciPy one?

Code after:
# functions in stats._util.

from itertools import product, combinations_with_replacement, permutations
import os
import re
import pickle
import pytest
import warnings

import numpy as np
from numpy.testing import assert_allclose, assert_equal
from scipy import stats, special
from scipy.stats._axis_nan_policy import (_masked_arrays_2_sentinel_arrays,
                                          SmallSampleWarning,
                                          too_small_nd_omit, too_small_nd_not_omit,
                                          too_small_1d_omit, too_small_1d_not_omit)
from scipy._lib._util import AxisError
from scipy.conftest import skip_xp_invalid_arg


SCIPY_XSLOW = int(os.environ.get('SCIPY_XSLOW', '0'))


def _using_accelerate():
    config = np.show_config('dicts')
    return config['Build Dependencies']['blas']['name'].lower() == 'accelerate'


RTOL = 1e-6 if _using_accelerate() else 1e-15


def unpack_ttest_result(res):
    low, high = res.confidence_interval()
    return (res.statistic, res.pvalue, res.df, res._standard_error,
            res._estimate, low, high)


def _get_ttest_ci(ttest):
    # get a function that returns the CI bounds of provided `ttest`
    def ttest_ci(*args, **kwargs):
        res = ttest(*args, **kwargs)
        return res.confidence_interval()
    return ttest_ci


def xp_mean_1samp(*args, **kwargs):
    kwargs.pop('_no_deco', None)
    return stats._stats_py._xp_mean(*args, **kwargs)


def xp_mean_2samp(*args, **kwargs):