Skip to content

Commit

Permalink
docs: use unitsystem in example (#165)
Browse files Browse the repository at this point in the history
* docs: use unitsystem in example
* build: bump unxt
* fix: jit changes error messages

Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman authored Aug 21, 2024
1 parent bfaffb8 commit 38e6619
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"plum-dispatch>=2.5.1",
"quax>=0.0.3",
"quaxed >= 0.4",
"unxt >= 0.10",
"unxt >= 0.15",
]
description = "Coordinates in JAX"
dynamic = ["version"]
Expand Down
6 changes: 3 additions & 3 deletions src/coordinax/_coordinax/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,13 @@ def to_units(self, units: Any, /) -> "AbstractVector":
Examples
--------
>>> import astropy.units as u
>>> from unxt import Quantity, UnitSystem
>>> from unxt import Quantity, unitsystem
>>> import coordinax as cx
>>> units = UnitSystem(u.m, u.s, u.kg, u.rad)
>>> usys = unitsystem(u.m, u.s, u.kg, u.rad)
>>> vec = cx.CartesianPosition3D.constructor([1, 2, 3], "km")
>>> vec.to_units(units)
>>> vec.to_units(usys)
CartesianPosition3D(
x=Quantity[...](value=f32[], unit=Unit("m")),
y=Quantity[...](value=f32[], unit=Unit("m")),
Expand Down
12 changes: 5 additions & 7 deletions src/coordinax/_coordinax/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def check_r_non_negative(
>>> x = Quantity([-1, 1, 2], "m")
>>> try: check_r_non_negative(x)
... except Exception as e: print(e)
The radial distance must be non-negative...
... except Exception: pass
"""
return eqx.error_if(r, xp.any(r < _l), "The radial distance must be non-negative.")
Expand All @@ -58,7 +57,7 @@ def check_azimuth_range(
>>> check_azimuth_range(x)
Quantity['angle'](Array([0., 1., 2.], dtype=float32), unit='deg')
Raise an error if anything is outside thr range.
Raise an error if anything is outside the range.
>>> x = Quantity([0., 1, 2], "m")
>>> try: check_azimuth_range(x)
Expand All @@ -67,8 +66,8 @@ def check_azimuth_range(
>>> x = Quantity([-1., 1, 2], "deg")
>>> try: check_azimuth_range(x)
... except Exception as e: print(e)
The azimuthal angle must be in the range [0, 2pi)...
... except Exception: pass
... except Exception: pass
"""
azimuth = eqx.error_if(
Expand Down Expand Up @@ -109,8 +108,7 @@ def check_polar_range(
>>> x = Quantity([-1., 1, 2], "deg")
>>> try: check_polar_range(x)
... except Exception as e: print(e)
The inclination angle must be in the range [0, pi]...
... except Exception: pass
"""
polar = eqx.error_if(
Expand Down

0 comments on commit 38e6619

Please sign in to comment.