<commit_before>import numpy
import cupy
import scipy.special
import cupyx.scipy.special

from cupy import testing
import pytest

scipy_ufuncs = {
    f
    for f in scipy.special.__all__
    if isinstance(getattr(scipy.special, f), numpy.ufunc)
}
cupyx_scipy_ufuncs = {
    f
    for f in dir(cupyx.scipy.special)
    if isinstance(getattr(cupyx.scipy.special, f), cupy.ufunc)
}


@testing.gpu
@testing.with_requires("scipy")
@pytest.mark.parametrize("ufunc", cupyx_scipy_ufuncs & scipy_ufuncs)
class TestUfunc:
    @testing.numpy_cupy_allclose(atol=1e-5)
    def test_dispatch(self, xp, ufunc):
        ufunc = getattr(scipy.special, ufunc)
        # some ufunc (like sph_harm) do not work with float inputs
        # therefore we retrieve the types from the ufunc itself
        types = ufunc.types[0]
        args = [
            cupy.testing.shaped_random((5,), xp, dtype=types[i])
            for i in range(ufunc.nargs - 1)
        ]
        res = ufunc(*args)
        assert type(res) == xp.ndarray
        return res<commit_msg>Use sorted on the set to parametrize tests so that pytest-xdist works<commit_after>import numpy
import cupy
import scipy.special
import cupyx.scipy.special

from cupy import testing
import pytest

scipy_ufuncs = {
    f
    for f in scipy.special.__all__
    if isinstance(getattr(scipy.special, f), numpy.ufunc)
}
cupyx_scipy_ufuncs = {
    f
    for f in dir(cupyx.scipy.special)
    if isinstance(getattr(cupyx.scipy.special, f), cupy.ufunc)
}

@testing.gpu
@testing.with_requires("scipy")
@pytest.mark.parametrize("ufunc", sorted(cupyx_scipy_ufuncs & scipy_ufuncs))
class TestUfunc:
    @testing.numpy_cupy_allclose(atol=1e-5)
    def test_dispatch(self, xp, ufunc):
        ufunc = getattr(scipy.special, ufunc)
        # some ufunc (like sph_harm) do not work with float inputs
        # therefore we retrieve the types from the ufunc itself
        types = ufunc.types[0]
        args = [
            cupy.testing.shaped_random((5,), xp, dtype=types[i])
            for i in range(ufunc.nargs - 1)
        ]
        res = ufunc(*args)
        assert type(res) == xp.ndarray
        return res
{'fraction_non_alphanumeric': 0.09976580796252928, 'fraction_numerical': 0.00468384074941452, 'mean_word_length': 3.030188679245283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1565230', 'n_tokens_mistral': 792, 'n_tokens_neox': 778, 'n_words': 182}