class_docstr: A general minimizer for curve fitting and optimization.
class_docstr_tok: ["A","general","minimizer","for","curve","fitting","and","optimization","."]
docstr: Prepare parameters for fitting.
  
  Prepares and initializes model and Parameters for subsequent
  fitting. This routine prepares the conversion of
  :class:`Parameters` into fit variables, organizes parameter bounds,
  and parses, "compiles" and checks constrain expressions. The method
  also creates and returns a new instance of a
  :class:`MinimizerResult` object that contains the copy of the
  Parameters that will actually be varied in the fit.
  
  Parameters
  ----------
  params : Parameters, optional
      Contains the Parameters for the model; if None, then the
      Parameters used to initialize the Minimizer object are used.
  
  Returns
  -------
  MinimizerResult
  
  Notes
  -----
  This method is called directly by the fitting methods, and it is
  generally not necessary to call this function explicitly.
  
  
  .. versionchanged:: 0.9.0
     Return value changed to :class:`MinimizerResult`.
docstr_tok: ["Prepare","parameters","for","fitting",".","Prepares","and","initializes","model","and","Parameters","for","subsequent","fitting",".","This","routine","prepares","the","conversion","of",":","class",":","`","Parameters","`","into","fit","variables",",","organizes","parameter","bounds",",","and","parses",",","``","compiles","''","and","checks","constrain","expressions",".","The","method","also","creates","and","returns","a","new","instance","of","a",":","class",":","`","MinimizerResult","`","object","that","contains","the","copy","of","the","Parameters","that","will","actually","be","varied","in","the","fit",".","Parameters","--","--","--","--","--","params",":","Parameters",",","optional","Contains","the","Parameters","for","the","model",";","if","None",",","then","the","Parameters","used","to","initialize","the","Minimizer","object","are","used",".","Returns","--","--","--","-","MinimizerResult","Notes","--","--","-","This","method","is","called","directly","by","the","fitting","methods",",","and","it","is","generally","not","necessary","to","call","this","function","explicitly",".","..","versionchanged",":",":","0.9.0","Return","value","changed","to",":","class",":","`","MinimizerResult","`","."]
code: def prepare_fit(self, params=None):
      """Prepare parameters for fitting.
  
      Prepares and initializes model and Parameters for subsequent
      fitting. This routine prepares the conversion of
      :class:`Parameters` into fit variables, organizes parameter bounds,
      and parses, "compiles" and checks constrain expressions. The method
      also creates and returns a new instance of a
      :class:`MinimizerResult` object that contains the copy of the
      Parameters that will actually be varied in the fit.
  
      Parameters
      ----------
      params : Parameters, optional
          Contains the Parameters for the model; if None, then the
          Parameters used to initialize the Minimizer object are used.
  
      Returns
      -------
      MinimizerResult
  
      Notes
      -----
      This method is called directly by the fitting methods, and it is
      generally not necessary to call this function explicitly.
  
  
      .. versionchanged:: 0.9.0
         Return value changed to :class:`MinimizerResult`.
  
      """
      self._abort = False
  
      self.result = MinimizerResult()
      result = self.result
      if params is not None:
          self.params = params
      if isinstance(self.params, Parameters):
          result.params = deepcopy(self.params)
      elif isinstance(self.params, (list, tuple)):
          result.params = Parameters()
          for par in self.params:
              if not isinstance(par, Parameter):
                  raise MinimizerException(self._err_nonparam)
              else:
                  result.params[par.name] = par
      elif self.params is None:
          raise MinimizerException(self._err_nonparam)
  
      # determine which parameters are actually variables
      # and which are defined expressions.
      result.var_names = []  # note that this *does* belong to self...
      result.init_vals = []
      result._init_vals_internal = []
      result.params.update_constraints()
      result.nfev = 0
      result.call_kws = {}
      result.errorbars = False
      result.aborted = False
      result.success = True
      result.covar = None
  
      for name, par in self.result.params.items():
          par.stderr = None
          par.correl = None
          if par.expr is not None:
              par.vary = False
          if par.vary:
              result.var_names.append(name)
              result._init_vals_internal.append(par.setup_bounds())
              result.init_vals.append(par.value)
  
          par.init_value = par.value
          if par.name is None:
              par.name = name
      result.nvarys = len(result.var_names)
      result.init_values = {
          n: v for n, v in zip(result.var_names, result.init_vals)
      }
  
      # set up reduce function for scalar minimizers
      #    1. user supplied callable
      #    2. string starting with 'neglogc' or 'negent'
      #    3. sum-of-squares
      if not callable(self.reduce_fcn):
          if isinstance(self.reduce_fcn, str):
              if self.reduce_fcn.lower().startswith("neglogc"):
                  self.reduce_fcn = reduce_cauchylogpdf
              elif self.reduce_fcn.lower().startswith("negent"):
                  self.reduce_fcn = reduce_negentropy
          if self.reduce_fcn is None:
              self.reduce_fcn = reduce_chisquare
      return result
  
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 7 for calling the Minimizer obj's underlying member method code with example usage: obj.prepare_fit(params) and returns: result