pymc.backends.zarr.ZarrTrace.to_datatree#

ZarrTrace.to_datatree(save_warmup=False, eager=False)[source]#

Convert ZarrTrace to DataTree.

The zarr group hierarchy naturally translates into a DataTree, so this conversion opens the whole hierarchy with xarray.open_datatree(). The _sampling_state group is excluded, and the warmup groups are only included if save_warmup is True. Each group’s attributes are extended with the global tuning_steps and sampling_time metadata.

Parameters:
save_warmupbool

If True, all of the warmup groups are stored in the data tree.

eagerbool

If True, all of the data is loaded into memory. If False, the data is lazily loaded when accessed.

Notes

xarray requires the zarr groups to have consolidated metadata, which is written by calling zarr.consolidate_metadata() on the root’s store. Consolidated metadata is not (yet) part of the zarr v3 specification, so zarr will warn about it. The returned DataTree operates on freshly opened datasets, so future changes to the ZarrTrace are not reflected in it.