Skip to content

Commit

Permalink
docs: test sqrt
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman committed May 24, 2024
1 parent 0c727cc commit 60c0dd9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/unxt/_quantity/register_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3308,6 +3308,33 @@ def _sort_p_one_operand(

@register(lax.sqrt_p)
def _sqrt_p(x: AbstractQuantity) -> AbstractQuantity:
"""Square root of a quantity.
Examples
--------
>>> import quaxed.numpy as qnp
>>> from unxt import UncheckedQuantity
>>> q = UncheckedQuantity(9, "m")
>>> qnp.sqrt(q)
UncheckedQuantity(Array(3, dtype=float32, ...), unit='m1/2')
>>> from unxt import Quantity
>>> q = Quantity(9, "m")
>>> qnp.sqrt(q)
Quantity['length'](Array(3, dtype=float32, ...), unit='m1/2')
>>> from unxt import Distance
>>> q = Distance(9, "m")
>>> qnp.sqrt(q)
Quantity['length'](Array(3, dtype=float32, ...), unit='m1/2')
>>> from unxt import Parallax
>>> q = Parallax(9, "mas")
>>> qnp.sqrt(q)
Quantity['angle'](Array(3, dtype=float32, ...), unit='mas1/2')
"""
# Promote the Quantity to something that supports sqrt units.
# E.g. Distance -> Quantity
x = promote(x)[0]
Expand Down

0 comments on commit 60c0dd9

Please sign in to comment.