diff --git a/src/coordinax/_base.py b/src/coordinax/_base.py index f2ea4117..87c2f5a8 100644 --- a/src/coordinax/_base.py +++ b/src/coordinax/_base.py @@ -583,18 +583,21 @@ def to_units(self, units: Any) -> "AbstractVectorBase": usys = unitsystem(units) return replace( self, - **{k: v.to(usys[v.unit.physical_type]) for k, v in dataclass_items(self)}, + **{ + k: v.to_units(usys[v.unit.physical_type]) + for k, v in dataclass_items(self) + }, ) @dispatch def to_units( - self, units: Mapping[u.PhysicalType | str, Unit], / + self, units: Mapping[u.PhysicalType | str, Unit | str], / ) -> "AbstractVectorBase": """Convert the vector to the given units. Parameters ---------- - units : Mapping[PhysicalType | str, Unit] + units : Mapping[PhysicalType | str, Unit | str] The units to convert to according to the physical type of the components. @@ -628,7 +631,10 @@ def to_units( # Convert to the given units return replace( self, - **{k: v.to(units_[v.unit.physical_type]) for k, v in dataclass_items(self)}, + **{ + k: v.to_units(units_[v.unit.physical_type]) + for k, v in dataclass_items(self) + }, ) @dispatch @@ -678,7 +684,10 @@ def to_units( return replace( self, - **{k: v.to(units_[v.unit.physical_type]) for k, v in dataclass_items(self)}, + **{ + k: v.to_units(units_[v.unit.physical_type]) + for k, v in dataclass_items(self) + }, ) # =============================================================== diff --git a/src/coordinax/operators/_galilean/composite.py b/src/coordinax/operators/_galilean/composite.py index 2bc2aa7b..7e9f4065 100644 --- a/src/coordinax/operators/_galilean/composite.py +++ b/src/coordinax/operators/_galilean/composite.py @@ -113,7 +113,7 @@ class GalileanOperator(AbstractCompositeOperator, AbstractGalileanOperator): t=Quantity[PhysicalType('time')](value=f32[], unit=Unit("kpc s / km")), q=Cartesian3DVector( ... ) ) - >>> new.t.to("Gyr").value.round(2) + >>> new.t.to_units("Gyr").value.round(2) Array(2.5, dtype=float32) >>> new.q.x Quantity['length'](Array(3.5567803, dtype=float32), unit='kpc') diff --git a/src/coordinax/operators/_galilean/rotation.py b/src/coordinax/operators/_galilean/rotation.py index a0631391..1e710250 100644 --- a/src/coordinax/operators/_galilean/rotation.py +++ b/src/coordinax/operators/_galilean/rotation.py @@ -33,7 +33,7 @@ def converter(x: Any) -> Array: if isinstance(x, GalileanRotationOperator): out = x.rotation elif isinstance(x, Quantity): - out = x.to_value("") + out = x.to_units_value("") else: out = x return jnp.asarray(out) diff --git a/src/coordinax/operators/_galilean/translation.py b/src/coordinax/operators/_galilean/translation.py index 71990f12..a5183834 100644 --- a/src/coordinax/operators/_galilean/translation.py +++ b/src/coordinax/operators/_galilean/translation.py @@ -459,7 +459,7 @@ def __call__(self: "GalileanTranslationOperator", x: FourVector, /) -> FourVecto >>> new.x Quantity['length'](Array(2., dtype=float32), unit='kpc') - >>> new.t.to("Gyr") + >>> new.t.to_units("Gyr") Quantity['time'](Array(0.99999994, dtype=float32), unit='Gyr') """ diff --git a/tests/test_d3.py b/tests/test_d3.py index 84c505ac..6eee3395 100644 --- a/tests/test_d3.py +++ b/tests/test_d3.py @@ -39,8 +39,8 @@ def test_neg_compare_apy( # # Try finding the poles # if hasattr(vector, "theta"): - # sel = (vector.theta.to_value("deg") != 0) & ( - # vector.theta.to_value("deg") != 180 + # sel = (vector.theta.to_units_value("deg") != 0) & ( + # vector.theta.to_units_value("deg") != 180 # ) # else: # sel = slice(None) @@ -49,8 +49,8 @@ def test_neg_compare_apy( # for c in vecsel.components: # unit = getattr(apyvecsel, c).unit # assert np.allclose( - # getattr(vecsel, c).to_value(unit), - # getattr(apyvecsel, c).to_value(unit), + # getattr(vecsel, c).to_units_value(unit), + # getattr(apyvecsel, c).to_units_value(unit), # atol=5e-7, # )