Registry / data / xarray-einstats

xarray-einstats

JSON →
library0.11.0pypypi✓ verified 24d ago

xarray-einstats is a Python library that provides a high-level API to combine the symbolic array manipulation of `einstats` with `xarray`'s labeled dimensions for statistical operations and linear algebra. It aims to simplify common data analysis tasks on `xarray.DataArray` and `xarray.Dataset` objects, enabling operations like reduction, broadcasting, and reshaping with `einops`-like patterns. The current version is 0.10.0, and it generally follows an irregular release cadence, with updates typically driven by new features or important bug fixes.

pip install xarray-einstats
INSTALL
IMPORT
SIG · XARRAY-EINSTATS
X
xarray-einstats
datapythonv0.11.0
Install
12.9s avg
Import
3334ms
Disk
321MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.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.95 runs
installs and imports cleanly · install 0.0s · import 3.402s · 319.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 12.9s · import 3.266s · 306MB
321MB installed
● package 321MB
Code
Verified usage

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

stats
import xarray_einstats.stats as xestats
The primary module for statistical functions.
mean
from xarray_einstats.stats import mean
A direct import for a specific statistical function.

This example demonstrates creating an xarray DataArray and then using `xarray-einstats.stats.mean` to calculate the mean along a specific dimension. It also shows a basic `einops`-like pattern for combining and summing dimensions using a dictionary in the `dims` argument.

import xarray as xr import numpy as np import xarray_einstats.stats as xestats # Create a dummy xarray DataArray data = xr.DataArray( np.random.normal(size=(2, 3, 4)), coords={"a": [0, 1], "b": [0, 1, 2], "c": [0, 1, 2, 3]}, dims=["a", "b", "c"], ) print("Original data:\n", data) # Calculate the mean along dimension 'b' mean_b = xestats.mean(data, dims="b") print("\nMean along 'b' dimension:\n", mean_b) # Use einops-like patterns for more complex operations # Reshape 'b c' into a new dimension '(b c)' and then sum sum_bc_flattened = xestats.sum(data, dims={"b c": "_"}) # '_' signifies a new dimension combining 'b' and 'c' print("\nSum after flattening 'b' and 'c' dimensions:\n", sum_bc_flattened)
Debug
Known issues
breakingAs of version 0.10.0, `xarray-einstats` requires Python 3.12 or newer. This is a significant bump from previous versions (e.g., 0.9.0+ required Python 3.10+).
fix
Upgrade your Python environment to 3.12 or newer. If you need to use an older Python version (e.g., 3.10 or 3.11), you must pin `xarray-einstats` to a version less than 0.10.0 (e.g., `xarray-einstats<0.10`).
affects: 0.10.0 and above
breakingVersion 0.10.0 introduced minimum version requirements for key dependencies: `xarray>=2024.2.0`, `scipy>=1.11.0`, `numpy>=1.25.0`, and `einstats>=0.7.0`. Older versions of these libraries are no longer supported.
fix
Ensure all dependent libraries are updated to their respective minimum versions before upgrading `xarray-einstats` to 0.10.0 or higher. Use `pip install xarray-einstats --upgrade` to let pip handle dependencies or manually update them.
affects: 0.10.0 and above
gotchaThe `dims` argument in `xarray-einstats` functions (e.g., `mean`, `sum`, `quantile`) accepts various formats: a string, a list of strings, or a dictionary for `einops`-like patterns. Misunderstanding the dictionary format, especially for reshaping or combining dimensions, is a common source of errors.
fix
Refer to the `einstats` and `xarray-einstats` documentation for detailed examples of `dims` argument usage. Start with simple string or list of strings for basic operations before moving to more complex dictionary patterns for `einops`-like reshaping.
affects: All versions
Upgrade
Version history
0.11.0latest on PyPI · released Jul 20, 2026
Audit
Dependencies
xarrayrequiredCore dependency for labeled array functionality (>=2024.2.0)
einstatsrequiredCore dependency for `einops`-like statistical operations (>=0.7.0)
numpyrequiredNumerical computing foundation (>=1.25.0)
scipyrequiredScientific computing functions, used by some statistical operations (>=1.11.0)
Agent activity
39 hits · last 30 days
node
30
OpenAI (training)
1
Resources
xarray-einstats — pip install xarray-einstats · libregistry