class_docstr: A general minimizer for curve fitting and optimization.
class_docstr_tok: ["A","general","minimizer","for","curve","fitting","and","optimization","."]
docstr: Residual function used for least-squares fit.
  
  With the new, candidate values of `fvars` (the fitting variables),
  this evaluates all parameters, including setting bounds and
  evaluating constraints, and then passes those to the user-supplied
  function to calculate the residual.
  
  Parameters
  ----------
  fvars : numpy.ndarray
      Array of new parameter values suggested by the minimizer.
  apply_bounds_transformation : bool, optional
      Whether to apply lmfits parameter transformation to constrain
      parameters (default is True). This is needed for solvers
      without built-in support for bounds.
  
  Returns
  -------
  numpy.ndarray
       The evaluated function values for given `fvars`.
docstr_tok: ["Residual","function","used","for","least-squares","fit",".","With","the","new",",","candidate","values","of","`","fvars","`","(","the","fitting","variables",")",",","this","evaluates","all","parameters",",","including","setting","bounds","and","evaluating","constraints",",","and","then","passes","those","to","the","user-supplied","function","to","calculate","the","residual",".","Parameters","--","--","--","--","--","fvars",":","numpy.ndarray","Array","of","new","parameter","values","suggested","by","the","minimizer",".","apply_bounds_transformation",":","bool",",","optional","Whether","to","apply","lmfits","parameter","transformation","to","constrain","parameters","(","default","is","True",")",".","This","is","needed","for","solvers","without","built-in","support","for","bounds",".","Returns","--","--","--","-","numpy.ndarray","The","evaluated","function","values","for","given","`","fvars","`","."]
code: def __residual(self, fvars, apply_bounds_transformation=True):
      """Residual function used for least-squares fit.
  
      With the new, candidate values of `fvars` (the fitting variables),
      this evaluates all parameters, including setting bounds and
      evaluating constraints, and then passes those to the user-supplied
      function to calculate the residual.
  
      Parameters
      ----------
      fvars : numpy.ndarray
          Array of new parameter values suggested by the minimizer.
      apply_bounds_transformation : bool, optional
          Whether to apply lmfits parameter transformation to constrain
          parameters (default is True). This is needed for solvers
          without built-in support for bounds.
  
      Returns
      -------
      numpy.ndarray
           The evaluated function values for given `fvars`.
  
      """
      params = self.result.params
  
      if fvars.shape == ():
          fvars = fvars.reshape((1,))
  
      for name, val in zip(self.result.var_names, fvars):
          if apply_bounds_transformation:
              params[name].value = params[name].from_internal(val)
          else:
              params[name].value = val
      params.update_constraints()
  
      if self.max_nfev is None:
          self.max_nfev = 200000 * (len(fvars) + 1)
  
      self.result.nfev += 1
      self.result.last_internal_values = fvars
      if self.result.nfev > self.max_nfev:
          self.result.aborted = True
          m = f"number of function evaluations > {self.max_nfev}"
          self.result.message = f"Fit aborted: {m}"
          self.result.success = False
          raise AbortFitException(
              f"fit aborted: too many function evaluations {self.max_nfev}"
          )
  
      out = self.userfcn(params, *self.userargs, **self.userkws)
  
      if callable(self.iter_cb):
          abort = self.iter_cb(
              params,
              self.result.nfev,
              out,
              *self.userargs,
              **self.userkws,
          )
          self._abort = self._abort or abort
  
      if self._abort:
          self.result.residual = out
          self.result.aborted = True
          self.result.message = "Fit aborted by user callback. Could not estimate error-bars."
          self.result.success = False
          raise AbortFitException("fit aborted by user.")
      else:
          return coerce_float64(out, nan_policy=self.nan_policy)
  
imports: from collections import namedtuple
  from copy import deepcopy
  import inspect
  import multiprocessing
  import numbers
  import warnings
  import numpy
  from scipy.linalg import LinAlgError, inv
  from scipy.optimize import basinhopping
  from scipy.optimize import brute
  from scipy.optimize import differential_evolution
  from scipy.optimize import dual_annealing
  from scipy.optimize import least_squares
  from scipy.optimize import leastsq
  from scipy.optimize import minimize
  from scipy.optimize import shgo
  from scipy.sparse import issparse
  from scipy.sparse.linalg import LinearOperator
  from scipy.stats import cauchy
  from scipy.stats import norm
  from ._ampgo import ampgo
  from .parameter import Parameter, Parameters
  from .printfuncs import fitreport_html_table
label_desc: Use image node_id 4 for calling the Minimizer obj's underlying member method code with example usage: obj.__residual(fvars, apply_bounds_transformation) and returns: coerce_float64