GalacticDynamics / unxt

Unitful Quantities in JAX
https://unxt.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

New API and choice of units backends #139

Open nstarman opened 4 months ago

nstarman commented 4 months ago

Currently the unxt package vendors a custom Quantity (and related) object as well as a UnitSystem (and related). The actual units and their conversions are managed by Astropy. To make unxt a tool for the general ML community it would be ideal to allow the user to choose what units backend to use.

This will require a fair bit of refactoring to decouple unxt from astropy.units. Instead of directly calling astropy functions we will need to develop more generic functions which can then refer to the chosen backend. I think we should lean into multiple dispatch and therefore draw inspiration from Unitful.jl. I'm envisioning

Dimensions-related API:

Dimensions-system-related API:

Units-related API:

UnitSystem-related API:

Quantity-related API:

Support other plum API.

Planned backend support:

nstarman commented 2 days ago

The new API is complete 🎉. What remains is good for a v2, where we offer choices of backends beyond Astropy. Users should see minimal changes, only a new Dimension and Unit object, which wrap the backend and provide improved features like array * unit = unxt.Quantity, not astropy.Quantity.