# xarray-einstats#

Stats, linear algebra and einops for xarray

## Overview#

As stated in their website:

xarray makes working with multi-dimensional labeled arrays simple, efficient and fun!

The code is often more verbose, but it is generally because it is clearer and thus less error prone and more intuitive. Here are some examples of such trade-off where we believe the increased clarity is worth the extra characters:

numpy

xarray

a[2, 5]

da.sel(drug="paracetamol", subject=5)

a.mean(axis=(0, 1))

da.mean(dim=("chain", "draw"))

a.reshape((-1, 10))

da.stack(sample=("chain", "draw"))

a.transpose(2, 0, 1)

da.transpose("drug", "chain", "draw")

In some other cases however, using xarray can result in overly verbose code that often also becomes less clear. xarray_einstats provides wrappers around some numpy and scipy functions (mostly numpy.linalg and scipy.stats) and around einops with an api and features adapted to xarray.

### Key features#

Label aware

Apply operations over named dimensions. Automatically aligns and broadcasts inputs, and preserves dimensions and coordinates.

Interoperability

Wrappers in xarray-einstats are designed to be minimal to preserve as many features from xarray as possible, for example, Dask support.

Batched operations

All operations can be batched over one or multiple dimensions.

Flexible inputs

DataArrays, Datasets and even GroupBy xarray objects can be used as inputs.

Get started with xarray-einstats

## Similar projects#

Here we list some similar projects we know of. Note that all of them are complementary and don’t overlap:

## Cite xarray-einstats#

If you use this software, please cite it using the following template and the version specific DOI provided by Zenodo. Click on the badge to go to the Zenodo page and select the DOI corresponding to the version you used

• Oriol Abril-Pla. (2022). arviz-devs/xarray-einstats <version>. Zenodo. <version_doi>

or in bibtex format:

@software{xarray_einstats2022,
author       = {Abril-Pla, Oriol},
title        = {{xarray-einstats}},
year         = 2022,
url          = {https://github.com/arviz-devs/xarray-einstats}
publisher    = {Zenodo},
version      = {<version>},
doi          = {<version_doi>},
}