Repository: scipy/scipy
File: scipy/stats/_hypotests.py (Python)

Code before:
        y[sup] = _cdf_cvm_inf(x[sup]) * (1 + 1./(12*n)) + _psi1_mod(x[sup]) / n
        y[x >= n/3] = 1

    if y.ndim == 0:
        return y[()]
    return y


def _cvm_result_to_tuple(res, _):
    return res.statistic, res.pvalue


@xp_capabilities(np_only=True)
@_axis_nan_policy_factory(CramerVonMisesResult, n_samples=1, too_small=1,
                          result_to_tuple=_cvm_result_to_tuple)
def cramervonmises(rvs, cdf, args=()):
    r"""Perform the one-sample Cramér-von Mises test for goodness of fit.

    This performs a test of the goodness of fit of a cumulative distribution
    function (cdf) :math:`F` compared to the empirical distribution function
    :math:`F_n` of observed random variates :math:`X_1, ..., X_n` that are
    assumed to be independent and identically distributed ([1]_).
    The null hypothesis is that the :math:`X_i` have cumulative distribution
    :math:`F`.

    The statistic `T` is weighted by the sample size `n`, and is defined as:

    .. math::
        T = n\omega^2 =
        \frac{1}{12n} + \sum_{i=1}^n \left[ \frac{2i-1}{2n} - F(x_i) \right]^2

    Parameters
    ----------
    rvs : array_like
        A 1-D array of observed values of the random variables :math:`X_i`.
        The sample must contain at least two observations.
    cdf : str or callable
        The cumulative distribution function :math:`F` to test the
        observations against. If a string, it should be the name of a
        distribution in `scipy.stats`. If a callable, that callable is used
        to calculate the cdf: ``cdf(x, *args) -> float``.
    args : tuple, optional
        Distribution parameters. These are assumed to be known; see Notes.

    Returns
    -------
    res : object with attributes
        statistic : float
            Cramér-von Mises statistic `T`.
        pvalue : float
            The p-value.

Review comment (suggestion):
Single backticks (without explicit [role](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#roles)) can be used for parameters, functions, and classes; double backticks are for (other, general) code. I think this is supposed to be math, so you need to specify the `:math:` role:
```suggestion
    The statistic :math:`T` is weighted by the sample size :math:`n`, and is defined as:
```

(Here and below)

Code after:
    """
    xp = array_namespace(x) if xp is None else xp
    x = xp.asarray(x)

    if n is None:
        y = _cdf_cvm_inf(x, xp=xp)
    else:
        # support of the test statistic is [12/n, n/3], see 1.1 in [2]
        y = xp.zeros_like(x, dtype=x.dtype)
        sup = (1./(12*n) < x) & (x < n/3.)
        # note: _psi1_mod does not include the term _cdf_cvm_inf(x) / 12
        # therefore, we need to add it here
        y = xpx.at(y)[sup].set(_cdf_cvm_inf(x[sup], xp=xp) * (1 + 1./(12*n))
                               + _psi1_mod(x[sup], xp=xp) / n)
        y = xpx.at(y)[x >= n/3].set(1.)

    return y[()] if y.ndim == 0 else y


def _cvm_result_to_tuple(res, _):
    return res.statistic, res.pvalue


@xp_capabilities(cpu_only=True,  # needs special function `kv`
                 skip_backends=[('dask.array', 'typical dask issues')], jax_jit=False)
@_axis_nan_policy_factory(CramerVonMisesResult, n_samples=1, too_small=1,
                          result_to_tuple=_cvm_result_to_tuple)
def cramervonmises(rvs, cdf, args=(), *, axis=0):
    r"""Perform the one-sample Cramér-von Mises test for goodness of fit.

    This performs a test of the goodness of fit of a cumulative distribution
    function (cdf) :math:`F` compared to the empirical distribution function
    :math:`F_n` of observed random variates :math:`X_1, ..., X_n` that are
    assumed to be independent and identically distributed ([1]_).
    The null hypothesis is that the :math:`X_i` have cumulative distribution
    :math:`F`.

    The test statistic :math:`T` is defined as in [1]_, where :math:`\omega^2`
    is the Cramér-von Mises criterion and :math:`x_i` are the observed values.

    .. math::
        T = n\omega^2 =
        \frac{1}{12n} + \sum_{i=1}^n \left[ \frac{2i-1}{2n} - F(x_i) \right]^2

    Parameters
    ----------
    rvs : array_like
        A 1-D array of observed values of the random variables :math:`X_i`.
        The sample must contain at least two observations.
    cdf : str or callable
        The cumulative distribution function :math:`F` to test the