class_docstr: Base class for mystic functions
  
  The 'function' method must be overwritten, thus allowing
  calls to the class instance to mimic calls to the function object.
  
  For example, if function is overwritten with the Rosenbrock function:
      >>> rosen = Rosenbrock(ndim=3)
      >>> rosen([1,1,1])
      0.
     
docstr: Provides a base class for mystic functions.
  
  Takes optional input 'ndim' (number of dimensions).
          
docstr_tok: ["Provides","a","base","class","for","mystic","functions",".","Takes","optional","input","'ndim","'","(","number","of","dimensions",")","."]
code: def __init__(self, ndim=None):
      """
      Provides a base class for mystic functions.
  
      Takes optional input 'ndim' (number of dimensions).
      """
      if self.minimizers is None:
          self.minimizers = []
      # raise NotImplementedError('minimizers have not been provided')
      nmin = len(self.minimizers)
  
      # set the number of dimensions
      try:  # fixed dimension
          self.ndim = len(self.minimizers[0] if nmin else None)
          fixed = True
          if ndim is None:
              ndim = self.ndim
      except TypeError:  # not fixed
          self.ndim = ndim
          fixed = False
      if fixed and ndim != self.ndim:
          raise ValueError(
              "number of dimensions is fixed (ndim=%d)" % self.ndim
          )
      elif not fixed and ndim is None:
          raise ValueError(
              "number of dimensions must be set (ndim=None)"
          )
  
      # set the minimizer (and adjust minimizers if not fixed)
      if not nmin:
          self.minimizers = list(self.minimizers)
          self.minimizer = None
      elif not fixed:  # XXX: should be array instead of tuple?
          self.minimizers = [tuple([m] * ndim) for m in self.minimizers]
          self.minimizer = self.minimizers[0]  # global *must* be first
      else:
          self.minimizers = list(self.minimizers)
          self.minimizer = self.minimizers[0]  # global *must* be first
  
      # get the mimima
      self.minima = list(map(self.function, self.minimizers))
      self.minimum = min(self.minima) if self.minima else None
      if self.minima and self.minima.index(self.minimum):
          raise ValueError("global minimum must be at index = 0")
      return
  
file_path: mystic/mystic/models/abstract_model.py
imports: from numpy import sum
  from mystic.forward_model import CostFactory
label_desc: Use image node_id 1 to create a new AbstractFunction object from inherited base classes: object with example: obj = AbstractFunction(ndim)