diff --git a/src/coordinax/_base_acc.py b/src/coordinax/_base_acc.py index 6ee2e60..f96d34a 100644 --- a/src/coordinax/_base_acc.py +++ b/src/coordinax/_base_acc.py @@ -94,18 +94,19 @@ def __neg__(self) -> "Self": >>> from unxt import Quantity >>> import coordinax as cx - >>> dr = cx.RadialVelocity(Quantity(1, "m/s")) - >>> -dr - RadialVelocity( d_r=Quantity[...]( value=i32[], unit=Unit("m / s") ) ) - - >>> dp = cx.PolarVelocity(Quantity(1, "m/s"), Quantity(1, "mas/yr")) - >>> neg_dp = -dp - >>> neg_dp.d_r - Quantity['speed'](Array(-1., dtype=float32), unit='m / s') - >>> neg_dp.d_phi - Quantity['angular frequency'](Array(-1., dtype=float32), unit='mas / yr') - - """ + >>> d2r = cx.RadialAcceleration.constructor([1], "m/s2") + >>> -d2r + RadialAcceleration( + d2_r=Quantity[PhysicalType('acceleration')](value=i32[], unit=Unit("m / s2")) ) + + >>> d2p = cx.PolarAcceleration(Quantity(1, "m/s2"), Quantity(1, "mas/yr2")) + >>> neg_d2p = -d2p + >>> neg_d2p.d2_r + Quantity['acceleration'](Array(-1., dtype=float32), unit='m / s2') + >>> neg_d2p.d2_phi + Quantity['angular acceleration'](Array(-1., dtype=float32), unit='mas / yr2') + + """ # noqa: E501 return replace(self, **{k: -v for k, v in field_items(self)}) # =============================================================== diff --git a/src/coordinax/_base_pos.py b/src/coordinax/_base_pos.py index c5fef81..f9b1ef2 100644 --- a/src/coordinax/_base_pos.py +++ b/src/coordinax/_base_pos.py @@ -121,6 +121,20 @@ def __neg__(self) -> "Self": """Negate the vector. The default implementation is to go through Cartesian coordinates. + + Examples + -------- + >>> import coordinax as cx + >>> vec = cx.CartesianPosition3D.constructor([1, 2, 3], "m") + >>> -vec + CartesianPosition3D( + x=Quantity[PhysicalType('length')](value=f32[], unit=Unit("m")), + y=Quantity[PhysicalType('length')](value=f32[], unit=Unit("m")), + z=Quantity[PhysicalType('length')](value=f32[], unit=Unit("m")) + ) + >>> (-vec).x + Quantity['length'](Array(-1., dtype=float32), unit='m') + """ cart = self.represent_as(self._cartesian_cls) return (-cart).represent_as(type(self)) diff --git a/src/coordinax/_base_vel.py b/src/coordinax/_base_vel.py index 19c409f..19e5473 100644 --- a/src/coordinax/_base_vel.py +++ b/src/coordinax/_base_vel.py @@ -110,7 +110,8 @@ def __neg__(self) -> "Self": -------- >>> from unxt import Quantity >>> import coordinax as cx - >>> dr = cx.RadialVelocity(Quantity(1, "m/s")) + + >>> dr = cx.RadialVelocity.constructor([1], "m/s") >>> -dr RadialVelocity( d_r=Quantity[...]( value=i32[], unit=Unit("m / s") ) ) diff --git a/src/coordinax/_d1/cartesian.py b/src/coordinax/_d1/cartesian.py index 08a2207..fc7b369 100644 --- a/src/coordinax/_d1/cartesian.py +++ b/src/coordinax/_d1/cartesian.py @@ -47,7 +47,6 @@ def __neg__(self) -> "Self": Examples -------- - >>> from unxt import Quantity >>> import coordinax as cx >>> q = cx.CartesianPosition1D.constructor([1], "kpc") >>> -q diff --git a/src/coordinax/_d3/cartesian.py b/src/coordinax/_d3/cartesian.py index 5733396..3d0b862 100644 --- a/src/coordinax/_d3/cartesian.py +++ b/src/coordinax/_d3/cartesian.py @@ -58,7 +58,6 @@ def __neg__(self) -> "Self": Examples -------- - >>> from unxt import Quantity >>> import coordinax as cx >>> q = cx.CartesianPosition3D.constructor([1, 2, 3], "kpc") >>> (-q).x diff --git a/src/coordinax/_dn/cartesian.py b/src/coordinax/_dn/cartesian.py index 0b4790e..2e0989f 100644 --- a/src/coordinax/_dn/cartesian.py +++ b/src/coordinax/_dn/cartesian.py @@ -108,8 +108,8 @@ def __neg__(self) -> "Self": A 3D vector: - >>> q = cx.CartesianPositionND(Quantity([1, 2, 3], "kpc")) - >>> (-q).q + >>> vec = cx.CartesianPositionND(Quantity([1, 2, 3], "kpc")) + >>> (-vec).q Quantity['length'](Array([-1., -2., -3.], dtype=float32), unit='kpc') """