unxts.api#
Abstract dispatch API for unxt.
Note
unxts.api is the canonical package. The legacy unxt-api distribution remains available as a thin backward-compatible shim that re-exports this package, so existing import unxt_api code keeps working unchanged.
unxts.api declares the abstract dispatch interfaces that unxt and other packages implement. It depends only on plum — not on jax, numpy or astropy — so a package can speak unxt’s API without pulling in its implementation.
Install#
uv add unxts.api
pip install unxts.api
At a glance#
unxts.api declares the function; unxt registers the implementation that runs.
import unxt as u
q = u.Q(5, "m")
u.uconvert("km", q)
u.uconvert here is unxt’s registered implementation of the abstract unxts.api.uconvert. To make your own type work with the same call, you register an implementation of your own — see Extending.
Pages#
Tutorial
Teach unxt about your own type — start here: make
unit_of,dimension_of,ustripanduconvertwork on a class of your own.
Discussion
Why an abstract dispatch API — what the separation between interface and implementation buys, and what it costs.
How-to
How to extend unxt with your own types — registering implementations, the common patterns, and debugging dispatch.
Reference
API — every abstract function, its signature and its registered implementations in
unxt.
Public API#
The abstract functions, by domain:
Domain |
Functions |
|---|---|
Dimensions |
|
Units |
|
Quantities |
|
Unit systems |
Every one is a plum dispatch function, so f.methods lists what is currently registered:
import unxts.api as uapi
uapi.dimension.methods
uapi.unit_of.methods
uapi.uconvert.methods
uapi.uconvert_value.methods
See also#
unxt documentation — the concrete implementation.
plum documentation — the dispatch library.