'%(super)s
In the special case where both `floc` and `fscale` are given, a
`ValueError` is raised if any value `x` in `data` does not satisfy
`floc < x < floc + fscale`.'

@inherit_docstring_from(rv_continuous)
def fit(self, data, *args, **kwds):

    f0 = (kwds.get('f0', None) or kwds.get('fa', None) or kwds.get('fix_a', None))
    f1 = (kwds.get('f1', None) or kwds.get('fb', None) or kwds.get('fix_b', None))
    floc = kwds.get('floc', None)
    fscale = kwds.get('fscale', None)
    if ((floc is None) or (fscale is None)):
        return super(beta_gen, self).fit(data, *args, **kwds)
    if ((f0 is not None) and (f1 is not None)):
        raise ValueError('All    parameters    fixed.    There    is    nothing    to    optimize.')
    data = ((np.ravel(data) - floc) / fscale)
    if (np.any((data <= 0)) or np.any((data >= 1))):
        raise FitDataError('beta', lower=floc, upper=(floc + fscale))
    xbar = data.mean()
    if ((f0 is not None) or (f1 is not None)):
        if (f0 is not None):
            b = f0
            data = (1 - data)
            xbar = (1 - xbar)
        else:
            b = f1
        a = ((b * xbar) / (1 - xbar))
        (theta, info, ier, mesg) = optimize.fsolve(_beta_mle_a, a, args=(b, len(data), np.log(data).sum()), full_output=True)
        if (ier != 1):
            raise FitSolverError(mesg=mesg)
        a = theta[0]
        if (f0 is not None):
            (a, b) = (b, a)
    else:
        s1 = np.log(data).sum()
        s2 = sc.log1p((- data)).sum()
        fac = (((xbar * (1 - xbar)) / data.var(ddof=0)) - 1)
        a = (xbar * fac)
        b = ((1 - xbar) * fac)
        (theta, info, ier, mesg) = optimize.fsolve(_beta_mle_ab, [a, b], args=(len(data), s1, s2), full_output=True)
        if (ier != 1):
            raise FitSolverError(mesg=mesg)
        (a, b) = theta
    return (a, b, floc, fscale)
