Metadata-Version: 2.3
Name: unxt
Version: 0.16.1
Summary: Quantities in JAX
Project-URL: Bug Tracker, https://github.com/GalacticDynamics/unxt/issues
Project-URL: Changelog, https://github.com/GalacticDynamics/unxt/releases
Project-URL: Discussions, https://github.com/GalacticDynamics/unxt/discussions
Project-URL: Homepage, https://github.com/GalacticDynamics/unxt
Author-email: Nathaniel Starkman <nstarman@users.noreply.github.com>
License: BSD 3-Clause License
        
        Copyright (c) 2023, Nathaniel Starkman.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the vector package developers nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: astropy>=6.0
Requires-Dist: dataclassish>=0.3
Requires-Dist: equinox>0.11
Requires-Dist: is-annotated>=1.0
Requires-Dist: jax>0.4
Requires-Dist: jaxlib>0.4
Requires-Dist: jaxtyping
Requires-Dist: optional-dependencies>=0.3
Requires-Dist: plum-dispatch>=2.4.3
Requires-Dist: quax>=0.0.3
Requires-Dist: quaxed>=0.5.2
Requires-Dist: xmmutablemap
Provides-Extra: all
Requires-Dist: astropy>=6.0; extra == 'all'
Requires-Dist: gala; extra == 'all'
Requires-Dist: matplotlib; extra == 'all'
Requires-Dist: zeroth; extra == 'all'
Provides-Extra: backend-astropy
Requires-Dist: astropy>=6.0; extra == 'backend-astropy'
Provides-Extra: dev
Requires-Dist: astropy>=6.0; extra == 'dev'
Requires-Dist: gala; extra == 'dev'
Requires-Dist: griffe<1.0; extra == 'dev'
Requires-Dist: hypothesis[numpy]; extra == 'dev'
Requires-Dist: jinja2==3.1; extra == 'dev'
Requires-Dist: matplotlib; extra == 'dev'
Requires-Dist: mkdocs-include-exclude-files==0.0.1; extra == 'dev'
Requires-Dist: mkdocs-material==9.5; extra == 'dev'
Requires-Dist: mkdocs==1.6.0; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.18; extra == 'dev'
Requires-Dist: mknotebooks==0.8; extra == 'dev'
Requires-Dist: nbconvert==7.16; extra == 'dev'
Requires-Dist: pygments==2.16.0; extra == 'dev'
Requires-Dist: pymdown-extensions==10.2; extra == 'dev'
Requires-Dist: pytest-arraydiff; extra == 'dev'
Requires-Dist: pytest-cov>=3; extra == 'dev'
Requires-Dist: pytest-github-actions-annotate-failures; extra == 'dev'
Requires-Dist: pytest-mpl; extra == 'dev'
Requires-Dist: pytest>=6; extra == 'dev'
Requires-Dist: pytkdocs-tweaks==0.0.8; extra == 'dev'
Requires-Dist: sybil; extra == 'dev'
Requires-Dist: zeroth; extra == 'dev'
Provides-Extra: docs
Requires-Dist: griffe<1.0; extra == 'docs'
Requires-Dist: jinja2==3.1; extra == 'docs'
Requires-Dist: mkdocs-include-exclude-files==0.0.1; extra == 'docs'
Requires-Dist: mkdocs-material==9.5; extra == 'docs'
Requires-Dist: mkdocs==1.6.0; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.18; extra == 'docs'
Requires-Dist: mknotebooks==0.8; extra == 'docs'
Requires-Dist: nbconvert==7.16; extra == 'docs'
Requires-Dist: pygments==2.16.0; extra == 'docs'
Requires-Dist: pymdown-extensions==10.2; extra == 'docs'
Requires-Dist: pytkdocs-tweaks==0.0.8; extra == 'docs'
Provides-Extra: interop-gala
Requires-Dist: gala; extra == 'interop-gala'
Provides-Extra: interop-mpl
Requires-Dist: matplotlib; extra == 'interop-mpl'
Requires-Dist: zeroth; extra == 'interop-mpl'
Provides-Extra: test
Requires-Dist: hypothesis[numpy]; extra == 'test'
Requires-Dist: pytest-arraydiff; extra == 'test'
Requires-Dist: pytest-cov>=3; extra == 'test'
Requires-Dist: pytest-github-actions-annotate-failures; extra == 'test'
Requires-Dist: pytest>=6; extra == 'test'
Requires-Dist: sybil; extra == 'test'
Provides-Extra: test-all
Requires-Dist: astropy>=6.0; extra == 'test-all'
Requires-Dist: gala; extra == 'test-all'
Requires-Dist: hypothesis[numpy]; extra == 'test-all'
Requires-Dist: matplotlib; extra == 'test-all'
Requires-Dist: pytest-arraydiff; extra == 'test-all'
Requires-Dist: pytest-cov>=3; extra == 'test-all'
Requires-Dist: pytest-github-actions-annotate-failures; extra == 'test-all'
Requires-Dist: pytest-mpl; extra == 'test-all'
Requires-Dist: pytest>=6; extra == 'test-all'
Requires-Dist: sybil; extra == 'test-all'
Requires-Dist: zeroth; extra == 'test-all'
Provides-Extra: test-mpl
Requires-Dist: pytest-mpl; extra == 'test-mpl'
Description-Content-Type: text/markdown

<h1 align='center'> unxt </h1>
<h2 align="center">Unitful Quantities in JAX</h2>

Unxt is unitful quantities and calculations in [JAX][jax], built on
[Equinox][equinox] and [Quax][quax].

Yes, it supports auto-differentiation (`grad`, `jacobian`, `hessian`) and
vectorization (`vmap`, etc).

## Installation

[![PyPI platforms][pypi-platforms]][pypi-link]
[![PyPI version][pypi-version]][pypi-link]

<!-- [![Conda-Forge][conda-badge]][conda-link] -->

```bash
pip install unxt
```

## [Documentation][rtd-link]

[![Documentation Status][rtd-badge]][rtd-link]

### Quick example

```python
from unxt import Quantity

x = Quantity(jnp.arange(1, 5, dtype=float), "kpc")
print(x)
# Quantity['length'](Array([1., 2., 3., 4.], dtype=float64), unit='kpc')

# Addition / Subtraction
print(x + x)
# Quantity['length'](Array([2., 4., 6., 8.], dtype=float64), unit='kpc')

# Multiplication / Division
print(2 * x)
# Quantity['length'](Array([2., 4., 6., 8.], dtype=float64), unit='kpc')

y = Quantity(jnp.arange(4, 8, dtype=float), "Gyr")

print(x / y)
# Quantity['speed'](Array([0.25      , 0.4       , 0.5       , 0.57142857], dtype=float64), unit='kpc / Gyr')

# Exponentiation
print(x**2)
# Quantity['area'](Array([0., 1., 4., 9.], dtype=float64), unit='kpc2')

# Unit Checking on operations
try:
    x + y
except Exception as e:
    print(e)
# 'Gyr' (time) and 'kpc' (length) are not convertible
```

`unxt` is built on [`quax`](https://github.com/patrick-kidger/quax), which
enables custom array-ish objects in JAX. For convenience we use the
[`quaxed`](https://pypi.org/project/quaxed/) library, which is just a
`quax.quaxify` wrapper around `jax` to avoid boilerplate code.

```python
from quaxed import grad, vmap
import quaxed.numpy as jnp

print(jnp.square(x))
# Quantity['area'](Array([ 1.,  4.,  9., 16.], dtype=float64), unit='kpc2')

print(qnp.power(x, 3))
# Quantity['volume'](Array([ 1.,  8., 27., 64.], dtype=float64), unit='kpc3')

print(vmap(grad(lambda x: x**3))(x))
# Quantity['area'](Array([ 3., 12., 27., 48.], dtype=float64), unit='kpc2')
```

Since `Quantity` is parametric, it can do runtime dimension checking!

```python
LengthQuantity = Quantity["length"]
print(LengthQuantity(2, "km"))
# Quantity['length'](Array(2, dtype=int64, weak_type=True), unit='km')

try:
    LengthQuantity(2, "s")
except ValueError as e:
    print(e)
# Physical type mismatch.
```

## Citation

[![DOI][zenodo-badge]][zenodo-link]

If you found this library to be useful and want to support the development and
maintenance of lower-level code libraries for the scientific community, please
consider citing this work.

## Development

[![codecov][codecov-badge]][codecov-link]
[![Actions Status][actions-badge]][actions-link]

We welcome contributions!

<!-- prettier-ignore-start -->
[equinox]: https://docs.kidger.site/equinox/
[jax]: https://jax.readthedocs.io/en/latest/
[quax]: https://github.com/patrick-kidger/quax

[actions-badge]:            https://github.com/GalacticDynamics/unxt/workflows/CI/badge.svg
[actions-link]:             https://github.com/GalacticDynamics/unxt/actions
[codecov-badge]:            https://codecov.io/gh/GalacticDynamics/unxt/graph/badge.svg
[codecov-link]:             https://codecov.io/gh/GalacticDynamics/unxt
[pypi-link]:                https://pypi.org/project/unxt/
[pypi-platforms]:           https://img.shields.io/pypi/pyversions/unxt
[pypi-version]:             https://img.shields.io/pypi/v/unxt
[rtd-badge]:                https://readthedocs.org/projects/unxt/badge/?version=latest
[rtd-link]:                 https://unxt.readthedocs.io/en/latest/?badge=latest
[zenodo-badge]:             https://zenodo.org/badge/734877295.svg
[zenodo-link]:              https://zenodo.org/doi/10.5281/zenodo.10850455

<!-- prettier-ignore-end -->
