unxt
unxt: A Python package for unit-aware computing with JAX - Published in JOSS (2025)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 8 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Repository
Unitful Quantities in JAX
Basic Info
- Host: GitHub
- Owner: GalacticDynamics
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Homepage: https://unxt.readthedocs.io/
- Size: 1.98 MB
Statistics
- Stars: 42
- Watchers: 1
- Forks: 4
- Open Issues: 14
- Releases: 77
Topics
Metadata Files
README.md
unxt
Unitful Quantities in JAX
Unxt is unitful quantities and calculations in JAX, built on Equinox and Quax.
Unxt supports JAX's compelling features:
- JIT compilation (
jit) - vectorization (
vmap, etc.) - auto-differentiation (
grad,jacobian,hessian) - GPU/TPU/multi-host acceleration
And best of all, unxt doesn't force you to use special unit-compatible
re-exports of JAX libraries. You can use unxt with existing JAX code, and with
quax's simple decorator, JAX will work with unxt.Quantity.
Installation
bash
pip install unxt
using uv
```bash
uv add unxt
```
from source, using pip
```bash pip install git+https://https://github.com/GalacticDynamics/unxt.git ```building from source
```bash cd /path/to/parent git clone https://https://github.com/GalacticDynamics/unxt.git cd unxt pip install -e . # editable mode ```Documentation
Quick example
```python import unxt as u import jax.numpy as jnp
x = u.Quantity(jnp.arange(1, 5, dtype=float), "km") print(x)
Quantity'length'
```
The constituent value and unit are accessible as attributes:
```python repr(x.value)
Array([1., 2., 3., 4.], dtype=float64)
repr(x.unit)
Unit("m")
```
Quantity objects obey the rules of unitful arithmetic.
```python
Addition / Subtraction
print(x + x) Quantity"length"
Multiplication / Division
print(2 * x) Quantity"length"
y = u.Quantity(jnp.arange(4, 8, dtype=float), "yr")
print(x / y)
Quantity'speed'
Exponentiation
print(x**2)
Quantity'area'
Unit checking on operations
try: x + y except Exception as e: print(e)
'yr' (time) and 'km' (length) are not convertible
```
Quantities can be converted to different units:
```python print(u.uconvert("m", x)) # via function
Quantity'length'
print(x.uconvert("m")) # via method
Quantity'length'
```
Since Quantity is parametric, it can do runtime dimension checking!
```python LengthQuantity = u.Quantity["length"] print(LengthQuantity(2, "km"))
Quantity'length'
try: LengthQuantity(2, "s") except ValueError as e: print(e)
Physical type mismatch.
```
unxt is built on quax, which enables custom array-ish objects in
JAX. For convenience we use the quaxed library, which is just a
quax.quaxify wrapper around jax to avoid boilerplate code.
[!NOTE]
Using
quaxedis optional. You can directly usequaxify, and even apply it to the top-level function instead of individual functions.
```python from quaxed import grad, vmap import quaxed.numpy as jnp
print(jnp.square(x))
Quantity'area'
print(jnp.power(x, 3))
Quantity'volume'
print(vmap(grad(lambda x: x**3))(x))
Quantity'area'
```
See the documentation for more examples and details of JIT and AD
Citation
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.
Contributing and Development
We welcome contributions! Contributions are how open source projects improve and grow.
To contribute to unxt, please
fork the repository, make a
development branch, develop on that branch, then
open a pull request from the
branch in your fork to main.
To report bugs, request features, or suggest other ideas, please open an issue.
For more information, see CONTRIBUTING.md.
Owner
- Name: GalacticDynamics
- Login: GalacticDynamics
- Kind: organization
- Repositories: 4
- Profile: https://github.com/GalacticDynamics
Galactic Dynamics
JOSS Publication
unxt: A Python package for unit-aware computing with JAX
Authors
Tags
Numerical Computing Scientific ComputingGitHub Events
Total
- Create event: 57
- Issues event: 35
- Release event: 31
- Watch event: 31
- Delete event: 21
- Issue comment event: 256
- Push event: 193
- Pull request review comment event: 14
- Pull request review event: 50
- Pull request event: 348
- Fork event: 4
Last Year
- Create event: 57
- Issues event: 35
- Release event: 31
- Watch event: 31
- Delete event: 21
- Issue comment event: 256
- Push event: 193
- Pull request review comment event: 14
- Pull request review event: 50
- Pull request event: 348
- Fork event: 4
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nathaniel Starkman | n****n | 302 |
| dependabot[bot] | 4****] | 25 |
| pre-commit-ci[bot] | 6****] | 24 |
| Adrian Price-Whelan | a****w@g****m | 6 |
| Raphael Erik Hviding | r****g@g****m | 2 |
| Colm Talbot | t****m@g****m | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 30
- Total pull requests: 469
- Average time to close issues: about 1 month
- Average time to close pull requests: 1 day
- Total issue authors: 5
- Total pull request authors: 8
- Average comments per issue: 1.37
- Average comments per pull request: 0.91
- Merged pull requests: 444
- Bot issues: 0
- Bot pull requests: 58
Past Year
- Issues: 27
- Pull requests: 274
- Average time to close issues: about 1 month
- Average time to close pull requests: 1 day
- Issue authors: 5
- Pull request authors: 8
- Average comments per issue: 1.44
- Average comments per pull request: 1.2
- Merged pull requests: 261
- Bot issues: 0
- Bot pull requests: 21
Top Authors
Issue Authors
- nstarman (22)
- adrn (11)
- ColmTalbot (2)
- TheSkyentist (2)
- meeseeksmachine (1)
- vadmbertr (1)
Pull Request Authors
- nstarman (492)
- meeseeksmachine (51)
- dependabot[bot] (37)
- pre-commit-ci[bot] (30)
- adrn (15)
- TheSkyentist (4)
- ColmTalbot (2)
- danielskatz (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 1,628 last-month
- Total dependent packages: 1
- Total dependent repositories: 0
- Total versions: 69
- Total maintainers: 2
pypi.org: unxt
Quantities in JAX
- Homepage: https://github.com/GalacticDynamics/unxt
- Documentation: https://unxt.readthedocs.io/
- 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.
-
Latest release: 1.6.3
published 8 months ago
Rankings
Dependencies
- actions/checkout v4 composite
- actions/download-artifact v4 composite
- hynek/build-and-inspect-python-package v2 composite
- pypa/gh-action-pypi-publish release/v1 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- codecov/codecov-action v3.1.4 composite
- pre-commit/action v3.0.0 composite
- array_api_jax_compat @ git+https://github.com/GalacticDynamics/array-api-jax-compat.git
- astropy *
- equinox *
- jax *
- jaxlib *
- jaxtyping *
- quax *
