class_docstr: Encapsulate emcee specific logic.
class_docstr_tok: ["Encapsulate","emcee","specific","logic","."]
docstr: Convert the posterior to an xarray dataset.
docstr_tok: ["Convert","the","posterior","to","an","xarray","dataset","."]
code: def posterior_to_xarray(self):
      """Convert the posterior to an xarray dataset."""
      # Use emcee3 syntax, else use emcee2
      if hasattr(self.sampler, "get_chain"):
          samples_ary = self.sampler.get_chain().swapaxes(0, 1)
      else:
          samples_ary = self.sampler.chain
  
      data = {
          var_name: (samples_ary[(..., idx)])
          for idx, var_name in zip(self.slices, self.var_names)
      }
      return dict_to_dataset(
          data,
          library=self.emcee,
          coords=self.coords,
          dims=self.dims,
          index_origin=self.index_origin,
      )
  
file_path: arviz/arviz/data/io_emcee.py
imports: import warnings
  from collections import OrderedDict
  import numpy
  import xarray
  from ..None import utils
  from .base import dict_to_dataset, generate_dims_coords, make_attrs
  from .inference_data import InferenceData
label_desc: Use image node_id 2 for calling the EmceeConverter obj's underlying member method code with example usage: obj.posterior_to_xarray() and returns: dict_to_dataset