Welcome to xyzpy’s documentation!

Azure CI Code Coverage LGTM Grade Documentation Status

xyzpy is python library for efficiently generating, manipulating and plotting data with a lot of dimensions, of the type that often occurs in numerical simulations. It stands wholly atop the labelled N-dimensional array library xarray. The project’s documentation is hosted on readthedocs.

The aim is to take the pain and errors out of generating and exploring data with a high number of possible parameters. This means:

  • you don’t have to write super nested for loops

  • you don’t have to remember which arrays/dimensions belong to which variables/parameters

  • you don’t have to parallelize over or distribute runs yourself

  • you don’t have to worry about loading, saving and merging disjoint data

  • you don’t need to guess when a set of runs is going to finish

  • you don’t have to write batch submission scripts or leave the notebook to use SGE, PBS or SLURM

As well as the ability to automatically parallelize over runs, xyzpy provides the Crop object that allows runs and results to be written to disk, these can then be run by any process with access to the files - e.g. a batch system such as SGE, PBS or SLURM - or just serve as a convenient persistent progress mechanism.

Once your data has been aggregated into a xarray.Dataset or pandas.DataFrame there exists many powerful visualization tools such as seaborn, altair, and holoviews / hvplot. To these xyzpy adds also a simple ‘oneliner’ interface for interactively plotting the data using bokeh, or for static, publication ready figures using matplotlib, whilst being able to see the dependence on up to 4 dimensions at once.

Quick-start

In [1]: import xyzpy as xyz
   ...: import time as time

In [2]: @xyz.label(var_names=['sum', 'diff'])
   ...: def sumdiff(a, b):
   ...:     time.sleep(0.5)
   ...:     return a + b, a - b
   ...:

In [3]: combos = {'a': range(1, 10), 'b': range(23, 27)}

In [4]: sumdiff.run_combos(combos, parallel=True)
100%|###########################################| 36/36 [00:06<00:00,  5.33it/s]
Out[4]:
<xarray.Dataset>
Dimensions:  (a: 9, b: 4)
Coordinates:
  * a        (a) int64 1 2 3 4 5 6 7 8 9
  * b        (b) int64 23 24 25 26
Data variables:
    sum      (a, b) int64 24 25 26 27 25 26 27 28 26 ... 31 32 33 34 32 33 34 35
    diff     (a, b) int64 -22 -23 -24 -25 -21 -22 ... -17 -18 -14 -15 -16 -17

Detailed Examples

These following examples are generated from the notebooks in docs/examples. They demonstrate more complete usage or advanced features of xyzpy.

Installation

xzypy is itself a pure python package and can be found on pypi, and now conda-forge (the recommended installation method). The core dependencies are:

and the optional plotting functionality is provided by:

The recommended way of installing these is also using the conda package manager. A development version of xyzpy can be installed directly from github using the command:

pip install -U git+https://github.com/jcmgray/xyzpy.git

Indices and tables