class_docstr: NDArray trace object
  
  Parameters
  ----------
  name: str
      Name of backend. This has no meaning for the NDArray backend.
  model: Model
      If None, the model is taken from the `with` context.
  vars: list of variables
      Sampling values will be stored for these variables. If None,
      `model.unobserved_RVs` is used.
class_docstr_tok: ["NDArray","trace","object","Parameters","--","--","--","--","--","name",":","str","Name","of","backend",".","This","has","no","meaning","for","the","NDArray","backend",".","model",":","Model","If","None",",","the","model","is","taken","from","the","`","with","`","context",".","vars",":","list","of","variables","Sampling","values","will","be","stored","for","these","variables",".","If","None",",","`","model.unobserved_RVs","`","is","used","."]
docstr: Perform chain-specific setup.
  
  Parameters
  ----------
  draws: int
      Expected number of draws
  chain: int
      Chain number
  sampler_vars: list of dicts
      Names and dtypes of the variables that are
      exported by the samplers.
docstr_tok: ["Perform","chain-specific","setup",".","Parameters","--","--","--","--","--","draws",":","int","Expected","number","of","draws","chain",":","int","Chain","number","sampler_vars",":","list","of","dicts","Names","and","dtypes","of","the","variables","that","are","exported","by","the","samplers","."]
code: def setup(self, draws, chain, sampler_vars=None) -> None:
      """Perform chain-specific setup.
  
      Parameters
      ----------
      draws: int
          Expected number of draws
      chain: int
          Chain number
      sampler_vars: list of dicts
          Names and dtypes of the variables that are
          exported by the samplers.
      """
      super().setup(draws, chain, sampler_vars)
  
      self.chain = chain
      if (
          self.samples
      ):  # Concatenate new array if chain is already present.
          old_draws = len(self)
          self.draws = old_draws + draws
          self.draw_idx = old_draws
          for varname, shape in self.var_shapes.items():
              old_var_samples = self.samples[varname]
              new_var_samples = np.zeros(
                  (draws,) + shape, self.var_dtypes[varname]
              )
              self.samples[varname] = np.concatenate(
                  (old_var_samples, new_var_samples), axis=0
              )
      else:  # Otherwise, make array of zeros for each variable.
          self.draws = draws
          for varname, shape in self.var_shapes.items():
              self.samples[varname] = np.zeros(
                  (draws,) + shape, dtype=self.var_dtypes[varname]
              )
  
      if sampler_vars is None:
          return
  
      if self._stats is None:
          self._stats = []
          for sampler in sampler_vars:
              data: Dict[str, np.ndarray] = dict()
              self._stats.append(data)
              for varname, dtype in sampler.items():
                  data[varname] = np.zeros(draws, dtype=dtype)
      else:
          for data, vars in zip(self._stats, sampler_vars):
              if vars.keys() != data.keys():
                  raise ValueError("Sampler vars can't change")
              for varname, dtype in vars.items():
                  old = data[varname]
                  new = np.zeros(draws, dtype=dtype)
                  data[varname] = np.concatenate([old, new])
  
file_path: pymc/pymc/backends/ndarray.py
imports: from typing import Any, Dict, List, Optional
  import numpy
  from pymc.backends import base
  from pymc.backends.base import MultiTrace
  from pymc.model import Model, modelcontext
label_desc: Use image node_id 2 for calling the NDArray obj's underlying member method code with example usage: obj.setup(draws, chain, sampler_vars) without return types