Welcome to xyzpy’s documentation!#

tests codecov Codacy Badge Docs PyPI Anaconda-Server Badge


xyzpy is a 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 exist many powerful visualization tools such as seaborn, altair, and holoviews / hvplot.

To these, xyzpy also adds 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.

Overview#

The following guides introduce the main parts of xyzpy:

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.

Development#