class_docstr: An ensemble MCMC sampler
  
  If you are upgrading from an earlier version of emcee, you might notice
  that some arguments are now deprecated. The parameters that control the
  proposals have been moved to the :ref:`moves-user` interface (``a`` and
  ``live_dangerously``), and the parameters related to parallelization can
  now be controlled via the ``pool`` argument (:ref:`parallel`).
  
  Args:
      nwalkers (int): The number of walkers in the ensemble.
      ndim (int): Number of dimensions in the parameter space.
      log_prob_fn (callable): A function that takes a vector in the
          parameter space as input and returns the natural logarithm of the
          posterior probability (up to an additive constant) for that
          position.
      moves (Optional): This can be a single move object, a list of moves,
          or a "weighted" list of the form ``[(emcee.moves.StretchMove(),
          0.1), ...]``. When running, the sampler will randomly select a
          move from this list (optionally with weights) for each proposal.
          (default: :class:`StretchMove`)
      args (Optional): A list of extra positional arguments for
          ``log_prob_fn``. ``log_prob_fn`` will be called with the sequence
          ``log_prob_fn(p, *args, **kwargs)``.
      kwargs (Optional): A dict of extra keyword arguments for
          ``log_prob_fn``. ``log_prob_fn`` will be called with the sequence
          ``log_prob_fn(p, *args, **kwargs)``.
      pool (Optional): An object with a ``map`` method that follows the same
          calling sequence as the built-in ``map`` function. This is
          generally used to compute the log-probabilities for the ensemble
          in parallel.
      backend (Optional): Either a :class:`backends.Backend` or a subclass
          (like :class:`backends.HDFBackend`) that is used to store and
          serialize the state of the chain. By default, the chain is stored
          as a set of numpy arrays in memory, but new backends can be
          written to support other mediums.
      vectorize (Optional[bool]): If ``True``, ``log_prob_fn`` is expected
          to accept a list of position vectors instead of just one. Note
          that ``pool`` will be ignored if this is ``True``.
          (default: ``False``)
      parameter_names (Optional[Union[List[str], Dict[str, List[int]]]]):
          names of individual parameters or groups of parameters. If
          specified, the ``log_prob_fn`` will recieve a dictionary of
          parameters, rather than a ``np.ndarray``.
class_docstr_tok: ["An","ensemble","MCMC","sampler","If","you","are","upgrading","from","an","earlier","version","of","emcee",",","you","might","notice","that","some","arguments","are","now","deprecated",".","The","parameters","that","control","the","proposals","have","been","moved","to","the",":","ref",":","`","moves-user","`","interface","(","``","a","``","and","``","live_dangerously","``",")",",","and","the","parameters","related","to","parallelization","can","now","be","controlled","via","the","``","pool","``","argument","(",":","ref",":","`","parallel","`",")",".","Args",":","nwalkers","(","int",")",":","The","number","of","walkers","in","the","ensemble",".","ndim","(","int",")",":","Number","of","dimensions","in","the","parameter","space",".","log_prob_fn","(","callable",")",":","A","function","that","takes","a","vector","in","the","parameter","space","as","input","and","returns","the","natural","logarithm","of","the","posterior","probability","(","up","to","an","additive","constant",")","for","that","position",".","moves","(","Optional",")",":","This","can","be","a","single","move","object",",","a","list","of","moves",",","or","a","``","weighted","''","list","of","the","form","``","[","(","emcee.moves.StretchMove","(",")",",","0.1",")",",","...","]","``",".","When","running",",","the","sampler","will","randomly","select","a","move","from","this","list","(","optionally","with","weights",")","for","each","proposal",".","(","default",":",":","class",":","`","StretchMove","`",")","args","(","Optional",")",":","A","list","of","extra","positional","arguments","for","``","log_prob_fn","``",".","``","log_prob_fn","``","will","be","called","with","the","sequence","``","log_prob_fn","(","p",",","*","args",",","*","*","kwargs",")","``",".","kwargs","(","Optional",")",":","A","dict","of","extra","keyword","arguments","for","``","log_prob_fn","``",".","``","log_prob_fn","``","will","be","called","with","the","sequence","``","log_prob_fn","(","p",",","*","args",",","*","*","kwargs",")","``",".","pool","(","Optional",")",":","An","object","with","a","``","map","``","method","that","follows","the","same","calling","sequence","as","the","built-in","``","map","``","function",".","This","is","generally","used","to","compute","the","log-probabilities","for","the","ensemble","in","parallel",".","backend","(","Optional",")",":","Either","a",":","class",":","`","backends.Backend","`","or","a","subclass","(","like",":","class",":","`","backends.HDFBackend","`",")","that","is","used","to","store","and","serialize","the","state","of","the","chain",".","By","default",",","the","chain","is","stored","as","a","set","of","numpy","arrays","in","memory",",","but","new","backends","can","be","written","to","support","other","mediums",".","vectorize","(","Optional","[","bool","]",")",":","If","``","True","``",",","``","log_prob_fn","``","is","expected","to","accept","a","list","of","position","vectors","instead","of","just","one",".","Note","that","``","pool","``","will","be","ignored","if","this","is","``","True","``",".","(","default",":","``","False","``",")","parameter_names","(","Optional","[","Union","[","List","[","str","]",",","Dict","[","str",",","List","[","int","]","]","]","]",")",":","names","of","individual","parameters","or","groups","of","parameters",".","If","specified",",","the","``","log_prob_fn","``","will","recieve","a","dictionary","of","parameters",",","rather","than","a","``","np.ndarray","``","."]
docstr: Calculate the vector of log-probability for the walkers
  
  Args:
      coords: (ndarray[..., ndim]) The position vector in parameter
          space where the probability should be calculated.
  
  This method returns:
  
  * log_prob: A vector of log-probabilities with one entry for each
    walker in this sub-ensemble.
  * blob: The list of meta data returned by the ``log_post_fn`` at
    this position or ``None`` if nothing was returned.
code: def compute_log_prob(self, coords):
      """Calculate the vector of log-probability for the walkers
  
      Args:
          coords: (ndarray[..., ndim]) The position vector in parameter
              space where the probability should be calculated.
  
      This method returns:
  
      * log_prob: A vector of log-probabilities with one entry for each
        walker in this sub-ensemble.
      * blob: The list of meta data returned by the ``log_post_fn`` at
        this position or ``None`` if nothing was returned.
  
      """
      p = coords
  
      # Check that the parameters are in physical ranges.
      if np.any(np.isinf(p)):
          raise ValueError("At least one parameter value was infinite")
      if np.any(np.isnan(p)):
          raise ValueError("At least one parameter value was NaN")
  
      # If the parmaeters are named, then switch to dictionaries
      if self.params_are_named:
          p = ndarray_to_list_of_dicts(p, self.parameter_names)
  
      # Run the log-probability calculations (optionally in parallel).
      if self.vectorize:
          results = self.log_prob_fn(p)
      else:
          # If the `pool` property of the sampler has been set (i.e. we want
          # to use `multiprocessing`), use the `pool`'s map method.
          # Otherwise, just use the built-in `map` function.
          if self.pool is not None:
              map_func = self.pool.map
          else:
              map_func = map
          results = list(map_func(self.log_prob_fn, p))
  
      try:
          log_prob = np.array([float(l[0]) for l in results])
          blob = [l[1:] for l in results]
      except (IndexError, TypeError):
          log_prob = np.array([float(l) for l in results])
          blob = None
      else:
          # Get the blobs dtype
          if self.blobs_dtype is not None:
              dt = self.blobs_dtype
          else:
              try:
                  with warnings.catch_warnings(record=True):
                      warnings.simplefilter(
                          "error", np.VisibleDeprecationWarning
                      )
                      try:
                          dt = np.atleast_1d(blob[0]).dtype
                      except Warning:
                          deprecation_warning(
                              "You have provided blobs that are not all the "
                              "same shape or size. This means they must be "
                              "placed in an object array. Numpy has "
                              "deprecated this automatic detection, so "
                              "please specify "
                              "blobs_dtype=np.dtype('object')"
                          )
                          dt = np.dtype("object")
              except ValueError:
                  dt = np.dtype("object")
              if dt.kind in "US":
                  # Strings need to be object arrays or we risk truncation
                  dt = np.dtype("object")
          blob = np.array(blob, dtype=dt)
  
          # Deal with single blobs properly
          shape = blob.shape[1:]
          if len(shape):
              axes = np.arange(len(shape))[np.array(shape) == 1] + 1
              if len(axes):
                  blob = np.squeeze(blob, tuple(axes))
  
      # Check for log_prob returning NaN.
      if np.any(np.isnan(log_prob)):
          raise ValueError("Probability function returned NaN")
  
      return log_prob, blob
  
imports: import warnings
  from itertools import count
  from typing import Dict, List, Optional, Union
  import numpy
  from .backends import Backend
  from .model import Model
  from .moves import StretchMove
  from .pbar import get_progress_bar
  from .state import State
  from .utils import deprecated, deprecation_warning
label_desc: Use image node_id 9 for calling the EnsembleSampler obj's underlying member method code with example usage: obj.compute_log_prob(coords) and returns: log_prob,  blob