Skip to main content

Equinox extension for scientific programming.

Project description

Zodiax

PyPI version License integration codecov Documentation


Zodiax is an differentiable object-oriented framework geared towards scientific programming and physical modelling. Its built on the JAX + Equinox ecosystem, inherits all of their functionality, and adds a series of extra methods to make working with physically representative classes simple and flexible. On top of that, it also adds a number of helpful optimisation and statistics tools often found in the physical sciences but not in the machine learning field. Zodiax was spun out from the development of dLux, a differentiable optics framework that still uses Zodiax as its core class structure.

Documentation: louisdesdoigts.github.io/zodiax/

Note: The Zodiax tutorials live in a separate repo. This allows users to directly download and run the notebooks, ensuring that the correct packages needed to run them are installed! It also allows for new tutorials and examples to be added quite easily, without needing to update the core library.

Contributors: Louis Desdoigts

Requires: Python 3.10+, Jax 0.4.25+

Installation:

pip install zodiax

Development installation:

pip install "zodiax[dev]"

Quickstart

Create a regular class that inherits from zodiax.Base

import jax
import zodiax as zdx
import jax.numpy as np

class Linear(zdx.Base):
    m : jax.Array
    b : jax.Array

    def __init__(self, m, b):
        self.m = m
        self.b = b

    def __call__(self, x):
        return self.m * x + self.b

linear = Linear(1., 1.)

Its that simple! The linear class is now a fully differentiable object that gives us all the benefits of jax with an object-oriented interface!

Manipulating leaves

Zodiax provides a number of methods to manipulate the leaves of a class. These methods allow you to update, add, multiply, divide, and perform other operations on the parameters of a class in a flexible and intuitive way. These update methods support three equivalent input styles:

  1. (parameters, values) positional style
  2. {parameter: value} dictionary style
  3. param=value keyword style
# 1) Positional: (parameters, values)
linear = linear.set(["m", "b"], [2.0, 0.5])

# 2) Dictionary: {parameter: value}
linear = linear.add({"m": 0.1, "b": -0.2})

# 3) Keyword: param=value
linear = linear.multiply(m=2.0, b=0.5)

Use whichever style is clearest for your workflow. The operations remain immutable and return new objects.

Next steps

There are two main tutorials for Zodiax. The first is the Building Classes tutorial, which give s a detailed overview of how to construct classes, how neasted object and paths work, and how to manipulate them. The second is the Optimisation and Inference tutorial, which gives an relatively complete overview of the how to perform the most common optimisation and inference problems using Zodiax objects, and introduces a lot of the various tools and methods provided by the repo. If you are familiar with both of those, then you pretty much know all of Zodiax!

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

zodiax-0.5.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

zodiax-0.5.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file zodiax-0.5.0.tar.gz.

File metadata

  • Download URL: zodiax-0.5.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for zodiax-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1d630483a6189c1cb65b90285537259f2ce4cf206407d0f7aece316e6a97ec22
MD5 90eff1943bccc798b3533c56a7e59676
BLAKE2b-256 75faa26cbb8896b6a98d1b2b7242491768f87152601c49b9ce3a61da85168dc1

See more details on using hashes here.

File details

Details for the file zodiax-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: zodiax-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for zodiax-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b823e8f532848e76adab5c36adfc9617f836add5d43f1c1e71c2ba7cabea09a
MD5 1853baf413e52f702541e8d4304f5e35
BLAKE2b-256 9940943c96d5ea9f691488d476a1adb791a37e63cf756277fddc25d6584f827a

See more details on using hashes here.

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