Registry / data / arviz-base

arviz-base

JSON →
library1.2.0pypypi✓ verified 85d ago

arviz-base is a Python package that provides core ArviZ features and converters, serving as a fundamental component of the modular ArviZ 1.0 ecosystem. It focuses on data structures, primarily leveraging `xarray.DataTree`, and conversion utilities from various probabilistic programming languages (PPLs). This library, currently at version 1.0.0, is under active development as part of the broader ArviZ refactoring, aiming for increased flexibility and a minimal dependency footprint.

pip install arviz-base
INSTALL
IMPORT
SIG · ARVIZ-BASE
A
arviz-base
datapythonv1.2.0
Install
8.8s avg
Import
1548ms
Disk
182MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.582s · 179.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 8.8s · import 1.514s · 172MB
182MB installed
● package 182MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

arviz_base
import arviz_base as az
import arviz as az_old; az_old.InferenceData()
arviz-base uses its own namespace; the old `arviz.InferenceData` has been replaced by `xarray.DataTree` in 1.0.
load_arviz_data
from arviz_base import load_arviz_data
Used for loading pre-packaged ArviZ example datasets.
from_dict
from arviz_base import from_dict
Used for converting Python dictionaries to `xarray.DataTree` following ArviZ conventions.

This quickstart demonstrates loading an example dataset using `load_arviz_data` and then extracting data with `extract`. It also shows how to convert raw Python dictionaries containing NumPy arrays into an ArviZ-compatible `xarray.DataTree` using `from_dict`.

import arviz_base as az import numpy as np # Load an example dataset provided by ArviZ Base idata = az.load_arviz_data("centered_eight") print(f"Loaded DataTree with groups: {list(idata.keys())}") # Extract a specific group, e.g., 'posterior', combining chain and draw dimensions extracted_data = az.extract(idata, group="posterior") print(f"\nExtracted posterior data shape: {extracted_data.sizes}") # Convert a simple dictionary to a DataTree my_data = { "posterior": { "alpha": np.random.normal(0, 1, size=(4, 500)), "beta": np.random.normal(0, 0.5, size=(4, 500)) } } custom_idata = az.from_dict(my_data) print(f"\nCustom DataTree with groups: {list(custom_idata.keys())}")
Debug
Known issues
breakingArviZ 1.0, of which arviz-base is a part, introduces a major refactoring. The central `arviz.InferenceData` object has been replaced by `xarray.DataTree`. Code relying on `InferenceData` attributes or methods will break.
fix
Migrate your data handling to use `xarray.DataTree` structures and `arviz_base`'s new conversion and extraction functions. Consult the ArviZ migration guide.
affects: 0.x to 1.0.0+
gotchaarviz-base is a minimal package focused on data structures and converters. For statistical computations or plotting, you will need `arviz-stats` and `arviz-plots` respectively, or install the overarching `arviz` package with necessary extras.
fix
If you require statistical summaries or visualizations, install `arviz-stats` (`pip install arviz-stats`) and `arviz-plots` (`pip install arviz-plots`), or install `arviz` with relevant I/O and plotting extras (e.g., `pip install "arviz[netcdf4,matplotlib]"`).
affects: 1.0.0+
gotchaI/O functionalities for formats like NetCDF, HDF5, or Zarr are provided via optional dependencies. `arviz-base` itself does not have these as hard requirements to maintain a minimal footprint.
fix
Install the specific I/O backend you need separately, e.g., `pip install netcdf4` or `pip install zarr`. When installing `arviz` (the meta-package), these can be specified as extras, e.g., `pip install "arviz[netcdf4]"`.
affects: 1.0.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'xarray'
The core dependency `xarray` is not installed, which is essential for `arviz-base`'s data structures like `DataTree`.
fix
Install xarray: `pip install xarray` or `pip install "arviz-base"` (which should pull `xarray` as a dependency).
AttributeError: module 'arviz' has no attribute 'InferenceData'
Attempting to use the deprecated `arviz.InferenceData` object directly with an ArviZ 1.0+ installation (or `arviz-base`). The `InferenceData` object has been replaced by `xarray.DataTree`.
fix
Update your code to use `xarray.DataTree` or `arviz_base`'s conversion functions like `from_dict` or `from_cmdstanpy` to create `DataTree` objects. Refer to the ArviZ migration guide for detailed steps.
ValueError: setting an array element with a sequence. The above exception was the direct cause of the following exception: ValueError: could not broadcast input array from shape (X,Y) into shape (Z,)
This error typically occurs when the input data (e.g., NumPy arrays or dictionaries) provided to conversion functions like `from_dict` or other ArviZ functions do not conform to the expected dimensionality or shape for creating a `DataTree` group.
fix
Ensure that the input arrays have consistent shapes and the correct number of dimensions corresponding to the `chain`, `draw`, and variable-specific dimensions expected by ArviZ. For instance, posterior samples usually require `(chain, draw, *variable_dimensions)`.
Upgrade
Version history
1.2.0latest on PyPI · released Jun 12, 2026
Audit
Dependencies
xarrayrequiredCore data structure (DataTree) and data manipulation.
numpyrequiredFundamental numerical computing.
typing-extensionsrequiredType hinting support.
netcdf4optionalOptional I/O backend for NetCDF files.
h5netcdfoptionalOptional I/O backend for HDF5-backed NetCDF files.
zarroptionalOptional I/O backend for Zarr arrays.
Agent activity
34 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources
arviz-base — pip install arviz-base · libregistry