Contributing reference#

Reference document for contributors. Here we document part of the private API of the library as well as the suite of developer commands and scripts configured and included in the repository.

tox commands#

xarray-einstats uses tox to automatically handle testing (locally and on GitHub actions), building documentation locally, formatting and linting.

Here are the tox commands available which should be executed as tox -e <command>


Modifies the files using black and isort so they comply with formatting requirements.


Runs black, isort, pylint and pydocstyle to check both code style, presence of documentation everywhere that follows numpydoc convention and catching some code errors and bad practices.


Uses sphinx-build to generate the documentation.


Deletes all doc cache and intermediate files to rebuild the docs from scratch the next time you use the docs command.


Uses gnome-open to open the documentation build by tox. Opens the homepage


Runs test suite with pytest

Private API#



_add_documented_method(cls, wrapped_cls, methods)

Register methods to XrRV classes and document them from a template.

XrRV(dist, *args, **kwargs)

Base random variable wrapper class.

_apply_nonreduce_func(func, da, dims, kwargs)

Help wrap functions with a single input that return an output with the same size.

_apply_reduce_func(func, da, dims, kwargs[, ...])

Help wrap functions with a single input that return an output after reducing some dimensions.

Linear Algebra#

PairHandler(all_dims, keep_dims)

_einsum_parent(dims, *operands[, keep_dims])

Preprocess inputs to call numpy.einsum or numpy.einsum_path.



Handle converting actual dimension names to placeholders for einops.

process_pattern_list(redims, handler[, ...])

Process a pattern list and convert it to an einops expression using placeholders.


Translate a string pattern to a list pattern.


Tutorial module with data for docs and quick testing.


Generate a Dataset with multiple variables, some with dimensions from mcmc sampling.


Generate a 4d DataArray representing a batch of matrices.