Skip to main content

Easily generate large parameter space data

Project description

symmray logo

tests codecov Docs PyPI Anaconda-Server Badge Pixi Badge


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 have 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 SLURM, PBS or SGE
  • you don't have to lose progress if your run is interrupted
  • you don't have to fiddle with CUDA_VISIBLE_DEVICES or taskset to assign GPU devices or CPU cores to different runs

To this data generation functionality, xyzpy adds a simple plotting interface accessed via ds.xyz.plot() that automatically maps dataset dimensions to visual elements including color, marker, marker size, line style, line width, subplot rows and columns, and text annotations. It also adds various other utilities for timing and tracking memory usage, and for visualizing matrices and high dimensional tensors.

Quick-start

Here's a simple example of generating and plotting a 5D function that uses the high level driver xyz.cultivate() to handle a full cycle of data generation:

import xyzpy as xyz

def foo(x, delta, p, amp=1.0, C=0.0):
    return {"fx": amp * (x - delta) ** p + C}

# cultivate!
# 0. annotate the function
# 1. write missing parameters combinations to disk ('sow')
# 2. compute those, with results stored persistenly to disk ('grow')
# 3. load results into a xarray.Dataset, merging with existing ('reap')
ds = xyz.cultivate(
    foo,
    # this specifies we'll return a dict of named data_vars ourselves
    var_names=None,
    # this specifies we'll harvest results to the file "foo.h5"
    data_name="foo.h5",
    # compute the outer product of these parameter combinations
    combos=dict(
        x=[-2 + i * 0.25 for i in range(17)],
        p=[1, 2, 3],
        delta=[0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
        C=[-2.0, 1.0, 4.0],
        amp=[-1.0, 1.0],
    ),
)

# plot!
# - we can map pretty much any coordinate to any visual property
# - we can map to a palette ("hue") as well as position within that ("color")
fig, axs = ds.xyz.plot(
    x="x",
    y="fx",
    yscale="symlog",
    ylabel="$f(x)$",
    hue="C",
    markeredgecolor="C",
    color="delta",
    marker="delta",
    col="p",
    row="amp",
    markersize=3,
)

# clean up!
# - if we didn't delete the dataset, next run will only compute missing data
!rm foo.h5

example

Please see the docs for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xyzpy-1.3.2.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xyzpy-1.3.2-py3-none-any.whl (128.4 kB view details)

Uploaded Python 3

File details

Details for the file xyzpy-1.3.2.tar.gz.

File metadata

  • Download URL: xyzpy-1.3.2.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xyzpy-1.3.2.tar.gz
Algorithm Hash digest
SHA256 cfb16e42e6c9552b5b5fa2e94487619588be1b09b2e2738fb167a82a8c72d13b
MD5 9cf06eae6a7e76b2631c689f0ac82dca
BLAKE2b-256 f71c275be1f4c61393caa182645b19e745325af5b10a2ac190ec94d79ca830dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for xyzpy-1.3.2.tar.gz:

Publisher: pypi-release.yml on jcmgray/xyzpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xyzpy-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: xyzpy-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 128.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xyzpy-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b879990c97c8744ed13417feb0ecefcaef42b89643eab25cc304aa716837856
MD5 e11a1f76531aae92db5b3751c68ea4c6
BLAKE2b-256 9f243e78b9b5e9fc4ec8f9dc3fc121c36ce4d5234cfc407e6a00f8cdbd76ad36

See more details on using hashes here.

Provenance

The following attestation bundles were made for xyzpy-1.3.2-py3-none-any.whl:

Publisher: pypi-release.yml on jcmgray/xyzpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page