# Buggy code
def fit(self, data, *args, **kwds):
    if len(args) > 0:
        raise TypeError("Too many arguments.")

    floc = kwds.pop("floc", None)
    fscale = kwds.pop("fscale", None)

    _remove_optimizer_parameters(kwds)

    if floc is not None and fscale is not None:
        # This check is for consistency with `rv_continuous.fit`.
        raise ValueError("All parameters fixed. There is nothing to optimize.")

    data = np.asarray(data)
    data_min = data.min()
    if floc is None:
        # ML estimate of the location is the minimum of the data.
        loc = data_min
    else:
        loc = floc
        if data_min < loc:
            # There are values that are less than the specified loc.
            raise FitDataError("expon", lower=floc, upper=np.inf)

    if fscale is None:
        # ML estimate of the scale is the shifted mean.
        scale = data.mean() - loc
    else:
        scale = fscale

    # We expect the return values to be floating point, so ensure it
    # by explicitly converting to float.
    return float(loc), float(scale)


# Traceback (RuntimeError)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-86-fb3d43a0acaa> in <module>
13        1.5754, 2.2669, 1.6383, 1.7696, 1.9079, 1.0955, 1.5637, 2.66  ,
14        1.746 , 1.5319, 2.0958,    np.nan])
---> 15 K = stats.exponnorm.fit(x)

/anaconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in fit(self, data, *args, **kwds)
2195                                          'scale' in kwds):
2196             # get distribution specific starting locations
-> 2197             start = self._fitstart(data)
2198             args += start[Narg:-2]
2199         loc = kwds.pop('loc', start[-2])

/anaconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in _fitstart(self, data, args)
2034         if args is None:
2035             args = (1.0,)*self.numargs
-> 2036         loc, scale = self._fit_loc_scale_support(data, *args)
2037         return args + (loc, scale)
2038

/anaconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in _fit_loc_scale_support(self, data, *args)
2287             return (data_b - b) + margin, 1
2288         else:
-> 2289             raise RuntimeError
2290
2291     def fit_loc_scale(self, data, *args):

RuntimeError:

# Fixed code
def fit(self, data, *args, **kwds):
    if len(args) > 0:
        raise TypeError("Too many arguments.")

    floc = kwds.pop("floc", None)
    fscale = kwds.pop("fscale", None)

    _remove_optimizer_parameters(kwds)

    if floc is not None and fscale is not None:
        # This check is for consistency with `rv_continuous.fit`.
        raise ValueError("All parameters fixed. There is nothing to optimize.")

    data = np.asarray(data)

    if not np.isfinite(data).all():
        raise RuntimeError("The data contains non-finite values.")

    data_min = data.min()

    if floc is None:
        # ML estimate of the location is the minimum of the data.
        loc = data_min
    else:
        loc = floc
        if data_min < loc:
            # There are values that are less than the specified loc.
            raise FitDataError("expon", lower=floc, upper=np.inf)

    if fscale is None:
        # ML estimate of the scale is the shifted mean.
        scale = data.mean() - loc
    else:
        scale = fscale

    # We expect the return values to be floating point, so ensure it
    # by explicitly converting to float.
    return float(loc), float(scale)