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

Code before:
    def moment(self, order, *args, **kwargs):
        return super().moment(order, *args, **kwargs)

    def stats(self, *args, **kwargs):
        return super().stats(*args, **kwargs)

    def std(self, *args, **kwargs):
        return super().std(*args, **kwargs)

    def support(self, *args, **kwargs):
        return super().support(*args, **kwargs)

    def var(self, *args, **kwargs):
        return super().var(*args, **kwargs)


_remove_scale_methods = ['entropy', 'interval', 'mean', 'median',
                         'moment', 'stats', 'std', 'support', 'var']
for method_name in _remove_scale_methods:
    # remove `scale` parameter from method documentation
    method = getattr(rv_discrete, method_name)
    doc = FunctionDoc(method)
    for i, param in enumerate(doc['Parameters']):
        if param.name == 'scale':
            break
    doc['Parameters'].pop(i)
    doc = str(doc).split("\n", 1)[1].lstrip(" \n")  # remove signature
    method.__doc__ = str(doc)


def _expect(fun, lb, ub, x0, inc, maxcount=1000, tolerance=1e-10,
            chunksize=32):
    """Helper for computing the expectation value of `fun`."""
    # short-circuit if the support size is small enough
    if (ub - lb) <= chunksize:
        supp = np.arange(lb, ub+1, inc)
        vals = fun(supp)
        return np.sum(vals)

    # otherwise, iterate starting from x0
    if x0 < lb:
        x0 = lb
    if x0 > ub:
        x0 = ub

    count, tot = 0, 0.
    # iterate over [x0, ub] inclusive
    for x in _iter_chunked(x0, ub+1, chunksize=chunksize, inc=inc):
        count += x.size
        delta = np.sum(fun(x))
        tot += delta

Review comment (suggestion):
```suggestion
    doc['Parameters'] = [p for p in doc['Parameters'] if p.name != 'scale']
```

Code after:
    def moment(self, order, *args, **kwargs):
        return super().moment(order, *args, **kwargs)

    def stats(self, *args, **kwargs):
        return super().stats(*args, **kwargs)

    def std(self, *args, **kwargs):
        return super().std(*args, **kwargs)

    def support(self, *args, **kwargs):
        return super().support(*args, **kwargs)

    def var(self, *args, **kwargs):
        return super().var(*args, **kwargs)


_remove_scale_methods = ['entropy', 'interval', 'mean', 'median',
                         'moment', 'stats', 'std', 'support', 'var']
for method_name in _remove_scale_methods:
    # remove `scale` parameter from method documentation
    method = getattr(rv_discrete, method_name)
    doc = FunctionDoc(method)
    doc['Parameters'] = [p for p in doc['Parameters'] if p.name != 'scale']
    doc = str(doc).split("\n", 1)[1].lstrip(" \n")  # remove signature
    method.__doc__ = str(doc)


def _expect(fun, lb, ub, x0, inc, maxcount=1000, tolerance=1e-10,
            chunksize=32):
    """Helper for computing the expectation value of `fun`."""
    # short-circuit if the support size is small enough
    if (ub - lb) <= chunksize:
        supp = np.arange(lb, ub+1, inc)
        vals = fun(supp)
        return np.sum(vals)

    # otherwise, iterate starting from x0
    if x0 < lb:
        x0 = lb
    if x0 > ub:
        x0 = ub

    count, tot = 0, 0.
    # iterate over [x0, ub] inclusive
    for x in _iter_chunked(x0, ub+1, chunksize=chunksize, inc=inc):
        count += x.size
        delta = np.sum(fun(x))
        tot += delta
        if abs(delta) < tolerance * x.size:
            break
        if count > maxcount: