def scalar_minimize(self, method='Nelder-Mead', **kws):
        """
        use one of the scaler minimization methods from scipy.
        Available methods include:
          Nelder-Mead
          Powell
          CG  (conjugate gradient)
          BFGS
          Newton-CG
          Anneal
          L-BFGS-B
          TNC
          COBYLA
          SLSQP

        If the objective function returns a numpy array instead
        of the expected scalar, the sum of squares of the array
        will be used.

        Note that bounds and constraints can be set on Parameters
        for any of these methods, so are not supported separately
        for those designed to use bounds.

        """
        if not HAS_SCALAR_MIN :
            raise NotImplementedError

        self.prepare_fit()

        maxfev = 1000*(self.nvarys + 1)
        opts = {'maxiter': maxfev}
        if method not in ('L-BFGS-B','TNC', 'SLSQP'):
            opts['maxfev'] = maxfev

        fmin_kws = dict(method=method, tol=self.toler, options=opts)

        fmin_kws.update(self.kws)
        fmin_kws.update(kws)
        def penalty(parvals):
            "local penalty function -- eval sum-squares residual"
            r = self.__residual(parvals)
            if isinstance(r, ndarray):
                r = (r*r).sum()
            return r

        ret = scipy_minimize(penalty, self.vars, **fmin_kws)
        del self.vars
        resid  = self.__residual(ret.x)
        ndata  = len(resid)
        chisqr = (resid**2).sum()
        nfree  = (ndata - self.nvarys)
        redchi = chisqr / nfree

        ofit = group = self.paramgroup
        if Group is not None:
            ofit = group.fit_details = Group()

        ofit.method    = method
        ofit.nfev      = ret.nfev
        ofit.success   = ret.success
        ofit.status    = ret.status
        group.nvarys   = self.nvarys
        group.nfree    = nfree
        group.residual = resid
        group.message  = ret.message
        group.chi_square  = chisqr
        group.chi_reduced = redchi
        group.errorbars   = False
dataset/ETHPy150Open xraypy/xraylarch/lib/fitting/minimizer.py/Minimizer.scalar_minimize/original