class_docstr: A general minimizer for curve fitting and optimization.
class_docstr_tok: ["A","general","minimizer","for","curve","fitting","and","optimization","."]
docstr: Parameters
  ----------
  userfcn : callable
      Objective function that returns the residual (difference
      between model and data) to be minimized in a least-squares
      sense. This function must have the signature::
  
          userfcn(params, *fcn_args, **fcn_kws)
  
  params : Parameters
      Contains the Parameters for the model.
  fcn_args : tuple, optional
      Positional arguments to pass to `userfcn`.
  fcn_kws : dict, optional
      Keyword arguments to pass to `userfcn`.
  iter_cb : callable, optional
      Function to be called at each fit iteration. This function
      should have the signature::
  
          iter_cb(params, iter, resid, *fcn_args, **fcn_kws)
  
      where `params` will have the current parameter values, `iter`
      the iteration number, `resid` the current residual array, and
      `*fcn_args` and `**fcn_kws` are passed to the objective
      function.
  scale_covar : bool, optional
      Whether to automatically scale the covariance matrix (default
      is True).
  nan_policy : {'raise', 'propagate', 'omit}, optional
      Specifies action if `userfcn` (or a Jacobian) returns NaN
      values. One of:
  
      - `'raise'` : a `ValueError` is raised (default)
      - `'propagate'` : the values returned from `userfcn` are un-altered
      - `'omit'` : non-finite values are filtered
  
  reduce_fcn : str or callable, optional
      Function to convert a residual array to a scalar value for the
      scalar minimizers. Optional values are (where `r` is the
      residual array):
  
      - None : sum-of-squares of residual (default)
  
         = (r*r).sum()
  
      - `'negentropy'` : neg entropy, using normal distribution
  
         = rho*log(rho).sum()`, where rho = exp(-r*r/2)/(sqrt(2*pi))
  
      - `'neglogcauchy'` : neg log likelihood, using Cauchy distribution
  
         = -log(1/(pi*(1+r*r))).sum()
  
      - callable : must take one argument (`r`) and return a float.
  
  calc_covar : bool, optional
      Whether to calculate the covariance matrix (default is True)
      for solvers other than ``'leastsq'`` and ``'least_squares'``.
      Requires the ``numdifftools`` package to be installed.
  max_nfev : int or None, optional
      Maximum number of function evaluations (default is None). The
      default value depends on the fitting method.
  **kws : dict, optional
      Options to pass to the minimizer being used.
  
  Notes
  -----
  The objective function should return the value to be minimized.
  For the Levenberg-Marquardt algorithm from :meth:`leastsq` or
  :meth:`least_squares`, this returned value must be an array, with
  a length greater than or equal to the number of fitting variables
  in the model. For the other methods, the return value can either be
  a scalar or an array. If an array is returned, the sum-of-squares
  of the array will be sent to the underlying fitting method,
  effectively doing a least-squares optimization of the return
  values. If the objective function returns non-finite values then a
  `ValueError` will be raised because the underlying solvers cannot
  deal with them.
  
  A common use for the `fcn_args` and `fcn_kws` would be to pass in
  other data needed to calculate the residual, including such things
  as the data array, dependent variable, uncertainties in the data,
  and other data structures for the model calculation.
docstr_tok: ["Parameters","--","--","--","--","--","userfcn",":","callable","Objective","function","that","returns","the","residual","(","difference","between","model","and","data",")","to","be","minimized","in","a","least-squares","sense",".","This","function","must","have","the","signature",":",":","userfcn","(","params",",","*","fcn_args",",","*","*","fcn_kws",")","params",":","Parameters","Contains","the","Parameters","for","the","model",".","fcn_args",":","tuple",",","optional","Positional","arguments","to","pass","to","`","userfcn","`",".","fcn_kws",":","dict",",","optional","Keyword","arguments","to","pass","to","`","userfcn","`",".","iter_cb",":","callable",",","optional","Function","to","be","called","at","each","fit","iteration",".","This","function","should","have","the","signature",":",":","iter_cb","(","params",",","iter",",","resid",",","*","fcn_args",",","*","*","fcn_kws",")","where","`","params","`","will","have","the","current","parameter","values",",","`","iter","`","the","iteration","number",",","`","resid","`","the","current","residual","array",",","and","`","*","fcn_args","`","and","`","*","*","fcn_kws","`","are","passed","to","the","objective","function",".","scale_covar",":","bool",",","optional","Whether","to","automatically","scale","the","covariance","matrix","(","default","is","True",")",".","nan_policy",":","{","'raise","'",",","'propagate","'",",","'omit","}",",","optional","Specifies","action","if","`","userfcn","`","(","or","a","Jacobian",")","returns","NaN","values",".","One","of",":","-","`","'raise","'","`",":","a","`","ValueError","`","is","raised","(","default",")","-","`","'propagate","'","`",":","the","values","returned","from","`","userfcn","`","are","un-altered","-","`","'omit","'","`",":","non-finite","values","are","filtered","reduce_fcn",":","str","or","callable",",","optional","Function","to","convert","a","residual","array","to","a","scalar","value","for","the","scalar","minimizers",".","Optional","values","are","(","where","`","r","`","is","the","residual","array",")",":","-","None",":","sum-of-squares","of","residual","(","default",")","=","(","r","*","r",")",".sum","(",")","-","`","'negentropy","'","`",":","neg","entropy",",","using","normal","distribution","=","rho","*","log","(","rho",")",".sum","(",")","`",",","where","rho","=","exp","(","-r","*","r\/2",")","\/","(","sqrt","(","2","*","pi",")",")","-","`","'neglogcauchy","'","`",":","neg","log","likelihood",",","using","Cauchy","distribution","=","-log","(","1\/","(","pi","*","(","1+r","*","r",")",")",")",".sum","(",")","-","callable",":","must","take","one","argument","(","`","r","`",")","and","return","a","float",".","calc_covar",":","bool",",","optional","Whether","to","calculate","the","covariance","matrix","(","default","is","True",")","for","solvers","other","than","``","'leastsq","'","``","and","``","'least_squares","'","``",".","Requires","the","``","numdifftools","``","package","to","be","installed",".","max_nfev",":","int","or","None",",","optional","Maximum","number","of","function","evaluations","(","default","is","None",")",".","The","default","value","depends","on","the","fitting","method",".","*","*","kws",":","dict",",","optional","Options","to","pass","to","the","minimizer","being","used",".","Notes","--","--","-","The","objective","function","should","return","the","value","to","be","minimized",".","For","the","Levenberg-Marquardt","algorithm","from",":","meth",":","`","leastsq","`","or",":","meth",":","`","least_squares","`",",","this","returned","value","must","be","an","array",",","with","a","length","greater","than","or","equal","to","the","number","of","fitting","variables","in","the","model",".","For","the","other","methods",",","the","return","value","can","either","be","a","scalar","or","an","array",".","If","an","array","is","returned",",","the","sum-of-squares","of","the","array","will","be","sent","to","the","underlying","fitting","method",",","effectively","doing","a","least-squares","optimization","of","the","return","values",".","If","the","objective","function","returns","non-finite","values","then","a","`","ValueError","`","will","be","raised","because","the","underlying","solvers","can","not","deal","with","them",".","A","common","use","for","the","`","fcn_args","`","and","`","fcn_kws","`","would","be","to","pass","in","other","data","needed","to","calculate","the","residual",",","including","such","things","as","the","data","array",",","dependent","variable",",","uncertainties","in","the","data",",","and","other","data","structures","for","the","model","calculation","."]
code: def __init__(
      self,
      userfcn,
      params,
      fcn_args=None,
      fcn_kws=None,
      iter_cb=None,
      scale_covar=True,
      nan_policy="raise",
      reduce_fcn=None,
      calc_covar=True,
      max_nfev=None,
      **kws,
  ):
      """
      Parameters
      ----------
      userfcn : callable
          Objective function that returns the residual (difference
          between model and data) to be minimized in a least-squares
          sense. This function must have the signature::
  
              userfcn(params, *fcn_args, **fcn_kws)
  
      params : Parameters
          Contains the Parameters for the model.
      fcn_args : tuple, optional
          Positional arguments to pass to `userfcn`.
      fcn_kws : dict, optional
          Keyword arguments to pass to `userfcn`.
      iter_cb : callable, optional
          Function to be called at each fit iteration. This function
          should have the signature::
  
              iter_cb(params, iter, resid, *fcn_args, **fcn_kws)
  
          where `params` will have the current parameter values, `iter`
          the iteration number, `resid` the current residual array, and
          `*fcn_args` and `**fcn_kws` are passed to the objective
          function.
      scale_covar : bool, optional
          Whether to automatically scale the covariance matrix (default
          is True).
      nan_policy : {'raise', 'propagate', 'omit}, optional
          Specifies action if `userfcn` (or a Jacobian) returns NaN
          values. One of:
  
          - `'raise'` : a `ValueError` is raised (default)
          - `'propagate'` : the values returned from `userfcn` are un-altered
          - `'omit'` : non-finite values are filtered
  
      reduce_fcn : str or callable, optional
          Function to convert a residual array to a scalar value for the
          scalar minimizers. Optional values are (where `r` is the
          residual array):
  
          - None : sum-of-squares of residual (default)
  
             = (r*r).sum()
  
          - `'negentropy'` : neg entropy, using normal distribution
  
             = rho*log(rho).sum()`, where rho = exp(-r*r/2)/(sqrt(2*pi))
  
          - `'neglogcauchy'` : neg log likelihood, using Cauchy distribution
  
             = -log(1/(pi*(1+r*r))).sum()
  
          - callable : must take one argument (`r`) and return a float.
  
      calc_covar : bool, optional
          Whether to calculate the covariance matrix (default is True)
          for solvers other than ``'leastsq'`` and ``'least_squares'``.
          Requires the ``numdifftools`` package to be installed.
      max_nfev : int or None, optional
          Maximum number of function evaluations (default is None). The
          default value depends on the fitting method.
      **kws : dict, optional
          Options to pass to the minimizer being used.
  
      Notes
      -----
      The objective function should return the value to be minimized.
      For the Levenberg-Marquardt algorithm from :meth:`leastsq` or
      :meth:`least_squares`, this returned value must be an array, with
      a length greater than or equal to the number of fitting variables
      in the model. For the other methods, the return value can either be
      a scalar or an array. If an array is returned, the sum-of-squares
      of the array will be sent to the underlying fitting method,
      effectively doing a least-squares optimization of the return
      values. If the objective function returns non-finite values then a
      `ValueError` will be raised because the underlying solvers cannot
      deal with them.
  
      A common use for the `fcn_args` and `fcn_kws` would be to pass in
      other data needed to calculate the residual, including such things
      as the data array, dependent variable, uncertainties in the data,
      and other data structures for the model calculation.
  
      """
      self.userfcn = userfcn
      self.userargs = fcn_args
      if self.userargs is None:
          self.userargs = []
  
      self.userkws = fcn_kws
      if self.userkws is None:
          self.userkws = {}
      for maxnfev_alias in ("maxfev", "maxiter"):
          if maxnfev_alias in kws:
              warnings.warn(
                  maxeval_warning.format(maxnfev_alias, "Minimizer"),
                  RuntimeWarning,
              )
              kws.pop(maxnfev_alias)
  
      self.kws = kws
      self.iter_cb = iter_cb
      self.calc_covar = calc_covar
      self.scale_covar = scale_covar
      self.max_nfev = max_nfev
      self.nfev = 0
      self.nfree = 0
      self.ndata = 0
      self.ier = 0
      self._abort = False
      self.success = True
      self.errorbars = False
      self.message = None
      self.lmdif_message = None
      self.chisqr = None
      self.redchi = None
      self.covar = None
      self.residual = None
      self.reduce_fcn = reduce_fcn
      self.params = params
      self.col_deriv = False
      self.jacfcn = None
      self.nan_policy = 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 1 to create a new Minimizer object  with example: obj = Minimizer(userfcn, params, fcn_args, fcn_kws, iter_cb, scale_covar, nan_policy, reduce_fcn, calc_covar, max_nfev)