diff --git a/src/coordinax/_coordinax/dn/base.py b/src/coordinax/_coordinax/dn/base.py index 3a47ded5..96fc3ee8 100644 --- a/src/coordinax/_coordinax/dn/base.py +++ b/src/coordinax/_coordinax/dn/base.py @@ -10,7 +10,7 @@ import equinox as eqx import quaxed.lax as qlax -import quaxed.numpy as qnp +import quaxed.numpy as jnp from coordinax._coordinax.base import AbstractVector from coordinax._coordinax.base_acc import AbstractAcceleration @@ -127,7 +127,7 @@ def flatten(self) -> "Self": (2,) """ - return replace(self, q=qnp.reshape(self.q, (self.size, self.q.shape[-1]), "C")) + return replace(self, q=jnp.reshape(self.q, (self.size, self.q.shape[-1]), "C")) def reshape(self, *shape: Any, order: str = "C") -> "Self": """Reshape the N-dimensional position. @@ -263,7 +263,7 @@ def flatten(self) -> "Self": """ return replace( - self, d_q=qnp.reshape(self.d_q, (self.size, self.d_q.shape[-1]), "C") + self, d_q=jnp.reshape(self.d_q, (self.size, self.d_q.shape[-1]), "C") ) def reshape(self, *shape: Any, order: str = "C") -> "Self": @@ -406,7 +406,7 @@ def flatten(self) -> "Self": """ return replace( - self, d2_q=qnp.reshape(self.d2_q, (self.size, self.d2_q.shape[-1]), "C") + self, d2_q=jnp.reshape(self.d2_q, (self.size, self.d2_q.shape[-1]), "C") ) def reshape(self, *shape: Any, order: str = "C") -> "Self": diff --git a/tests/test_base.py b/tests/test_base.py index e11fc227..62fd7024 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -10,7 +10,7 @@ import pytest import quaxed.array_api as xp -import quaxed.numpy as qnp +import quaxed.numpy as jnp from dataclassish import field_items from unxt import AbstractQuantity @@ -108,7 +108,7 @@ def test_flatten(self, vector): flat = vector.flatten() assert isinstance(flat, type(vector)) assert all( - qnp.array_equal(getattr(flat, c), getattr(vector, c).flatten()) + jnp.array_equal(getattr(flat, c), getattr(vector, c).flatten()) for c in vector.components ) @@ -120,7 +120,7 @@ def test_flatten(self, vector): flat = vec.flatten() assert isinstance(flat, type(vec)) assert all( - qnp.array_equal(getattr(flat, c).value, xp.ones(8)) for c in vec.components + jnp.array_equal(getattr(flat, c).value, xp.ones(8)) for c in vec.components ) def test_reshape(self, vector): @@ -129,7 +129,7 @@ def test_reshape(self, vector): reshaped = vector.reshape(2, -1) assert isinstance(reshaped, type(vector)) assert all( - qnp.array_equal(getattr(reshaped, c), getattr(vector, c).reshape(2, -1)) + jnp.array_equal(getattr(reshaped, c), getattr(vector, c).reshape(2, -1)) for c in vector.components ) @@ -141,7 +141,7 @@ def test_reshape(self, vector): reshaped = vec.reshape(1, 8) assert isinstance(reshaped, type(vec)) assert all( - qnp.array_equal(getattr(reshaped, c).value, xp.ones((1, 8))) + jnp.array_equal(getattr(reshaped, c).value, xp.ones((1, 8))) for c in vec.components ) @@ -156,7 +156,7 @@ def test_asdict(self, vector): for k, v in adict.items(): assert isinstance(k, str) assert isinstance(v, AbstractQuantity) - assert qnp.array_equal(v, getattr(vector, k)) + assert jnp.array_equal(v, getattr(vector, k)) # Test with a different dict_factory adict = vector.asdict(dict_factory=UserDict) diff --git a/tests/test_d1.py b/tests/test_d1.py index 2b07d1b3..cebbbe6c 100644 --- a/tests/test_d1.py +++ b/tests/test_d1.py @@ -2,7 +2,7 @@ import pytest -import quaxed.numpy as qnp +import quaxed.numpy as jnp from unxt import Quantity import coordinax as cx @@ -41,7 +41,7 @@ def test_cartesian1d_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) def test_cartesian1d_to_cartesian2d(self, vector): """Test ``coordinax.represent_as(CartesianPosition2D)``.""" @@ -50,16 +50,16 @@ def test_cartesian1d_to_cartesian2d(self, vector): ) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "km")) def test_cartesian1d_to_polar(self, vector): """Test ``coordinax.represent_as(PolarPosition)``.""" polar = vector.represent_as(cx.PolarPosition, phi=Quantity([0, 1, 2, 3], "rad")) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) def test_cartesian1d_to_cartesian3d(self, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" @@ -70,9 +70,9 @@ def test_cartesian1d_to_cartesian3d(self, vector): ) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "km")) - assert qnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) def test_cartesian1d_to_spherical(self, vector): """Test ``coordinax.represent_as(SphericalPosition)``.""" @@ -83,9 +83,9 @@ def test_cartesian1d_to_spherical(self, vector): ) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) - assert qnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) + assert jnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) def test_cartesian1d_to_cylindrical(self, vector): """Test ``coordinax.represent_as(CylindricalPosition)``.""" @@ -96,9 +96,9 @@ def test_cartesian1d_to_cylindrical(self, vector): ) assert isinstance(cylindrical, cx.CylindricalPosition) - assert qnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) - assert qnp.array_equal(cylindrical.z, Quantity([4, 5, 6, 7], "m")) + assert jnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(cylindrical.z, Quantity([4, 5, 6, 7], "m")) class TestRadialPosition(AbstractPosition1DTest): @@ -117,7 +117,7 @@ def test_radial_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) def test_radial_to_radial(self, vector): """Test ``coordinax.represent_as(RadialPosition)``.""" @@ -136,16 +136,16 @@ def test_radial_to_cartesian2d(self, vector): ) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "km")) def test_radial_to_polar(self, vector): """Test ``coordinax.represent_as(PolarPosition)``.""" polar = vector.represent_as(cx.PolarPosition, phi=Quantity([0, 1, 2, 3], "rad")) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) def test_radial_to_cartesian3d(self, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" @@ -156,9 +156,9 @@ def test_radial_to_cartesian3d(self, vector): ) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "km")) - assert qnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) def test_radial_to_spherical(self, vector): """Test ``coordinax.represent_as(SphericalPosition)``.""" @@ -169,9 +169,9 @@ def test_radial_to_spherical(self, vector): ) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) - assert qnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) + assert jnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) def test_radial_to_cylindrical(self, vector): """Test ``coordinax.represent_as(CylindricalPosition)``.""" @@ -182,9 +182,9 @@ def test_radial_to_cylindrical(self, vector): ) assert isinstance(cylindrical, cx.CylindricalPosition) - assert qnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) - assert qnp.array_equal(cylindrical.z, Quantity([4, 5, 6, 7], "m")) + assert jnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(cylindrical.z, Quantity([4, 5, 6, 7], "m")) class AbstractVelocity1DTest(AbstractVelocityTest): @@ -224,7 +224,7 @@ def test_cartesian1d_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialVelocity, vector) assert isinstance(radial, cx.RadialVelocity) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -235,8 +235,8 @@ def test_cartesian1d_to_cartesian2d(self, difntl, vector): ) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -247,8 +247,8 @@ def test_cartesian1d_to_polar(self, difntl, vector): ) assert isinstance(polar, cx.PolarVelocity) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(polar.d_phi, Quantity([0, 1, 2, 3], "rad/s")) + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(polar.d_phi, Quantity([0, 1, 2, 3], "rad/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -262,9 +262,9 @@ def test_cartesian1d_to_cartesian3d(self, difntl, vector): ) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km")) - assert qnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -278,9 +278,9 @@ def test_cartesian1d_to_spherical(self, difntl, vector): ) assert isinstance(spherical, cx.SphericalVelocity) - assert qnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "kpc")) assert spherical.d_theta == Quantity([4, 5, 6, 7], "rad/s") - assert qnp.array_equal(spherical.d_phi, Quantity([0, 1, 2, 3], "rad/s")) + assert jnp.array_equal(spherical.d_phi, Quantity([0, 1, 2, 3], "rad/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -294,9 +294,9 @@ def test_cartesian1d_to_cylindrical(self, difntl, vector): ) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cylindrical.d_phi, Quantity([0, 1, 2, 3], "rad/s")) - assert qnp.array_equal(cylindrical.d_z, Quantity([4, 5, 6, 7], "m/s")) + assert jnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cylindrical.d_phi, Quantity([0, 1, 2, 3], "rad/s")) + assert jnp.array_equal(cylindrical.d_z, Quantity([4, 5, 6, 7], "m/s")) class TestRadialVelocity(AbstractVelocity1DTest): @@ -321,7 +321,7 @@ def test_radial_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") def test_radial_to_radial(self, difntl, vector): @@ -343,8 +343,8 @@ def test_radial_to_cartesian2d(self, difntl, vector): ) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -355,8 +355,8 @@ def test_radial_to_polar(self, difntl, vector): ) assert isinstance(polar, cx.PolarVelocity) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(polar.d_phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(polar.d_phi, Quantity([0, 1, 2, 3], "rad")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -370,9 +370,9 @@ def test_radial_to_cartesian3d(self, difntl, vector): ) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km")) - assert qnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km")) + assert jnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -386,9 +386,9 @@ def test_radial_to_spherical(self, difntl, vector): ) assert isinstance(spherical, cx.SphericalVelocity) - assert qnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "kpc")) assert spherical.d_theta == Quantity([4, 5, 6, 7], "rad") - assert qnp.array_equal(spherical.d_phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(spherical.d_phi, Quantity([0, 1, 2, 3], "rad")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -402,6 +402,6 @@ def test_radial_to_cylindrical(self, difntl, vector): ) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cylindrical.d_phi, Quantity([0, 1, 2, 3], "rad")) - assert qnp.array_equal(cylindrical.d_z, Quantity([4, 5, 6, 7], "m")) + assert jnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cylindrical.d_phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(cylindrical.d_z, Quantity([4, 5, 6, 7], "m")) diff --git a/tests/test_d2.py b/tests/test_d2.py index f0fe19e5..54c761d1 100644 --- a/tests/test_d2.py +++ b/tests/test_d2.py @@ -3,7 +3,7 @@ import pytest import quaxed.array_api as xp -import quaxed.numpy as qnp +import quaxed.numpy as jnp from unxt import Quantity import coordinax as cx @@ -33,7 +33,7 @@ def test_cartesian2d_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_cartesian2d_to_radial(self, vector): @@ -41,7 +41,7 @@ def test_cartesian2d_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.r, qnp.hypot(vector.x, vector.y)) + assert jnp.array_equal(radial.r, jnp.hypot(vector.x, vector.y)) def test_cartesian2d_to_cartesian2d(self, vector): """Test ``coordinax.represent_as(CartesianPosition2D)``.""" @@ -63,8 +63,8 @@ def test_cartesian2d_to_polar(self, vector): polar = vector.represent_as(cx.PolarPosition) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.r, qnp.hypot(vector.x, vector.y)) - assert qnp.allclose( + assert jnp.array_equal(polar.r, jnp.hypot(vector.x, vector.y)) + assert jnp.allclose( polar.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad"), atol=Quantity(1e-8, "deg"), @@ -77,9 +77,9 @@ def test_cartesian2d_to_cartesian3d(self, vector): ) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "kpc")) - assert qnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart3d.y, Quantity([5, 6, 7, 8], "kpc")) + assert jnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) def test_cartesian2d_to_spherical(self, vector): """Test ``coordinax.represent_as(SphericalPosition)``.""" @@ -88,13 +88,13 @@ def test_cartesian2d_to_spherical(self, vector): ) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal(spherical.r, qnp.hypot(vector.x, vector.y)) - assert qnp.allclose( + assert jnp.array_equal(spherical.r, jnp.hypot(vector.x, vector.y)) + assert jnp.allclose( spherical.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad"), atol=Quantity(1e-8, "rad"), ) - assert qnp.array_equal( + assert jnp.array_equal( spherical.theta, Quantity(xp.full(4, fill_value=xp.pi / 2), "rad") ) @@ -105,12 +105,12 @@ def test_cartesian2d_to_cylindrical(self, vector): ) assert isinstance(cylindrical, cx.CylindricalPosition) - assert qnp.array_equal(cylindrical.rho, qnp.hypot(vector.x, vector.y)) - assert qnp.array_equal( + assert jnp.array_equal(cylindrical.rho, jnp.hypot(vector.x, vector.y)) + assert jnp.array_equal( cylindrical.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad"), ) - assert qnp.array_equal(cylindrical.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cylindrical.z, Quantity([9, 10, 11, 12], "m")) class TestPolarPosition: @@ -132,12 +132,12 @@ def test_polar_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.allclose( + assert jnp.allclose( cart1d.x, Quantity([1.0, 1.0806047, -1.2484405, -3.95997], "kpc"), atol=Quantity(1e-8, "kpc"), ) - assert qnp.array_equal(cart1d.x, vector.r * xp.cos(vector.phi)) + assert jnp.array_equal(cart1d.x, vector.r * xp.cos(vector.phi)) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_polar_to_radial(self, vector): @@ -145,7 +145,7 @@ def test_polar_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) def test_polar_to_cartesian2d(self, vector): """Test ``coordinax.represent_as(CartesianPosition2D)``.""" @@ -154,16 +154,16 @@ def test_polar_to_cartesian2d(self, vector): ) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.x, Quantity([1.0, 1.0806046, -1.2484405, -3.95997], "kpc") ) - assert qnp.allclose( + assert jnp.allclose( cart2d.x, (vector.r * xp.cos(vector.phi)), atol=Quantity(1e-8, "kpc") ) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.y, Quantity([0.0, 1.6829419, 2.7278922, 0.56448], "kpc") ) - assert qnp.allclose( + assert jnp.allclose( cart2d.y, (vector.r * xp.sin(vector.phi)), atol=Quantity(1e-8, "kpc") ) @@ -184,13 +184,13 @@ def test_polar_to_cartesian3d(self, vector): ) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.x, Quantity([1.0, 1.0806046, -1.2484405, -3.95997], "kpc") ) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.y, Quantity([0.0, 1.6829419, 2.7278922, 0.56448], "kpc") ) - assert qnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cart3d.z, Quantity([9, 10, 11, 12], "m")) def test_polar_to_spherical(self, vector): """Test ``coordinax.represent_as(SphericalPosition)``.""" @@ -199,9 +199,9 @@ def test_polar_to_spherical(self, vector): ) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) - assert qnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.theta, Quantity([4, 15, 60, 170], "deg")) + assert jnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) def test_polar_to_cylindrical(self, vector): """Test ``coordinax.represent_as(CylindricalPosition)``.""" @@ -210,9 +210,9 @@ def test_polar_to_cylindrical(self, vector): ) assert isinstance(cylindrical, cx.CylindricalPosition) - assert qnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) - assert qnp.array_equal(cylindrical.z, Quantity([9, 10, 11, 12], "m")) + assert jnp.array_equal(cylindrical.rho, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cylindrical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(cylindrical.z, Quantity([9, 10, 11, 12], "m")) class AbstractVelocity2DTest(AbstractVelocityTest): @@ -247,7 +247,7 @@ def test_cartesian2d_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -256,7 +256,7 @@ def test_cartesian2d_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialVelocity, vector) assert isinstance(radial, cx.RadialVelocity) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") def test_cartesian2d_to_cartesian2d(self, difntl, vector): @@ -275,8 +275,8 @@ def test_cartesian2d_to_polar(self, difntl, vector): polar = difntl.represent_as(cx.PolarVelocity, vector) assert isinstance(polar, cx.PolarVelocity) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal( + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal( polar.d_phi, Quantity([5.0, 3.0, 2.3333335, 1.9999999], "km rad / (kpc s)"), ) @@ -290,9 +290,9 @@ def test_cartesian2d_to_cartesian3d(self, difntl, vector): ) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km/s")) - assert qnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m/s")) + assert jnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -303,9 +303,9 @@ def test_cartesian2d_to_spherical(self, difntl, vector): ) assert isinstance(spherical, cx.SphericalVelocity) - assert qnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(spherical.d_theta, Quantity([4, 5, 6, 7], "rad")) - assert qnp.array_equal(spherical.d_phi, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(spherical.d_theta, Quantity([4, 5, 6, 7], "rad")) + assert jnp.array_equal(spherical.d_phi, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -316,9 +316,9 @@ def test_cartesian2d_to_cylindrical(self, difntl, vector): ) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cylindrical.d_phi, Quantity([5, 6, 7, 8], "km/s")) - assert qnp.array_equal(cylindrical.d_z, Quantity([9, 10, 11, 12], "m/s")) + assert jnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cylindrical.d_phi, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cylindrical.d_z, Quantity([9, 10, 11, 12], "m/s")) class TestPolarVelocity(AbstractVelocity2DTest): @@ -349,7 +349,7 @@ def test_polar_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -358,7 +358,7 @@ def test_polar_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialVelocity, vector) assert isinstance(radial, cx.RadialVelocity) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") def test_polar_to_cartesian2d(self, difntl, vector): @@ -366,10 +366,10 @@ def test_polar_to_cartesian2d(self, difntl, vector): cart2d = difntl.represent_as(cx.CartesianVelocity2D, vector) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.d_x, Quantity([1.0, -46.787014, -91.76889, -25.367176], "km/s") ) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.d_y, Quantity([23.702353, 32.418385, -38.69947, -149.61249], "km/s"), ) @@ -394,9 +394,9 @@ def test_polar_to_cartesian3d(self, difntl, vector): ) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km/s")) - assert qnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m/s")) + assert jnp.array_equal(cart3d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart3d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart3d.d_z, Quantity([9, 10, 11, 12], "m/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -407,9 +407,9 @@ def test_polar_to_spherical(self, difntl, vector): ) assert isinstance(spherical, cx.SphericalVelocity) - assert qnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(spherical.d_theta, Quantity([4, 5, 6, 7], "rad")) - assert qnp.array_equal(spherical.d_phi, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(spherical.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(spherical.d_theta, Quantity([4, 5, 6, 7], "rad")) + assert jnp.array_equal(spherical.d_phi, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -420,6 +420,6 @@ def test_polar_to_cylindrical(self, difntl, vector): ) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cylindrical.d_phi, Quantity([5, 6, 7, 8], "km/s")) - assert qnp.array_equal(cylindrical.d_z, Quantity([9, 10, 11, 12], "m/s")) + assert jnp.array_equal(cylindrical.d_rho, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cylindrical.d_phi, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cylindrical.d_z, Quantity([9, 10, 11, 12], "m/s")) diff --git a/tests/test_d3.py b/tests/test_d3.py index c93b1b5f..dd981b26 100644 --- a/tests/test_d3.py +++ b/tests/test_d3.py @@ -8,7 +8,7 @@ from plum import convert import quaxed.array_api as xp -import quaxed.numpy as qnp +import quaxed.numpy as jnp from unxt import Quantity import coordinax as cx @@ -81,7 +81,7 @@ def test_cartesian3d_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart1d.x, Quantity([1, 2, 3, 4], "kpc")) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_cartesian3d_to_radial(self, vector): @@ -89,7 +89,7 @@ def test_cartesian3d_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal( + assert jnp.array_equal( radial.r, Quantity([10.34408, 11.83216, 13.379088, 14.96663], "kpc") ) @@ -101,8 +101,8 @@ def test_cartesian3d_to_cartesian2d(self, vector): ) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "kpc")) + assert jnp.array_equal(cart2d.x, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(cart2d.y, Quantity([5, 6, 7, 8], "kpc")) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_cartesian3d_to_polar(self, vector): @@ -110,8 +110,8 @@ def test_cartesian3d_to_polar(self, vector): polar = vector.represent_as(cx.PolarPosition, phi=Quantity([0, 1, 2, 3], "rad")) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.r, qnp.hypot(vector.x, vector.y)) - assert qnp.array_equal( + assert jnp.array_equal(polar.r, jnp.hypot(vector.x, vector.y)) + assert jnp.array_equal( polar.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad") ) @@ -138,13 +138,13 @@ def test_cartesian3d_to_spherical(self, vector): spherical = vector.represent_as(cx.SphericalPosition) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal( + assert jnp.array_equal( spherical.r, Quantity([10.34408, 11.83216, 13.379088, 14.96663], "kpc") ) - assert qnp.array_equal( + assert jnp.array_equal( spherical.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad") ) - assert qnp.allclose( + assert jnp.allclose( spherical.theta, Quantity([0.51546645, 0.5639427, 0.6055685, 0.64052236], "rad"), atol=Quantity(1e-8, "rad"), @@ -164,12 +164,12 @@ def test_cartesian3d_to_cylindrical(self, vector): cylindrical = vector.represent_as(cx.CylindricalPosition) assert isinstance(cylindrical, cx.CylindricalPosition) - assert qnp.array_equal(cylindrical.rho, qnp.hypot(vector.x, vector.y)) - assert qnp.array_equal( + assert jnp.array_equal(cylindrical.rho, jnp.hypot(vector.x, vector.y)) + assert jnp.array_equal( cylindrical.phi, Quantity([1.3734008, 1.2490457, 1.1659045, 1.1071488], "rad"), ) - assert qnp.array_equal(cylindrical.z, Quantity([9.0, 10, 11, 12], "kpc")) + assert jnp.array_equal(cylindrical.z, Quantity([9.0, 10, 11, 12], "kpc")) def test_cartesian3d_to_cylindrical_astropy(self, vector, apyvector): """Test Astropy equivalence.""" @@ -207,7 +207,7 @@ def test_cylindrical_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.allclose( + assert jnp.allclose( cart1d.x, Quantity([1.0, 1.0806047, -1.2484405, -3.95997], "kpc"), atol=Quantity(1e-8, "kpc"), @@ -219,7 +219,7 @@ def test_cylindrical_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_cylindrical_to_cartesian2d(self, vector): @@ -227,10 +227,10 @@ def test_cylindrical_to_cartesian2d(self, vector): cart2d = vector.represent_as(cx.CartesianPosition2D) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.x, Quantity([1.0, 1.0806046, -1.2484405, -3.95997], "kpc") ) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.y, Quantity([0.0, 1.6829419, 2.7278922, 0.56448], "kpc") ) @@ -240,21 +240,21 @@ def test_cylindrical_to_polar(self, vector): polar = vector.represent_as(cx.PolarPosition) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(polar.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(polar.phi, Quantity([0, 1, 2, 3], "rad")) def test_cylindrical_to_cartesian3d(self, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" cart3d = vector.represent_as(cx.CartesianPosition3D) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.x, Quantity([1.0, 1.0806046, -1.2484405, -3.95997], "kpc") ) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.y, Quantity([0.0, 1.6829419, 2.7278922, 0.56448], "kpc") ) - assert qnp.array_equal(cart3d.z, vector.z) + assert jnp.array_equal(cart3d.z, vector.z) def test_cylindrical_to_cartesian3d_astropy(self, vector, apyvector): """Test Astropy equivalence.""" @@ -270,9 +270,9 @@ def test_cylindrical_to_spherical(self, vector): spherical = vector.represent_as(cx.SphericalPosition) assert isinstance(spherical, cx.SphericalPosition) - assert qnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) - assert qnp.array_equal(spherical.theta, Quantity(xp.full(4, xp.pi / 2), "rad")) - assert qnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) + assert jnp.array_equal(spherical.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(spherical.theta, Quantity(xp.full(4, xp.pi / 2), "rad")) + assert jnp.array_equal(spherical.phi, Quantity([0, 1, 2, 3], "rad")) def test_cylindrical_to_spherical_astropy(self, vector, apyvector): """Test Astropy equivalence.""" @@ -328,7 +328,7 @@ def test_spherical_to_cartesian1d(self, vector): cart1d = vector.represent_as(cx.CartesianPosition1D) assert isinstance(cart1d, cx.CartesianPosition1D) - assert qnp.allclose( + assert jnp.allclose( cart1d.x, Quantity( [1.7452406e-02, 4.9681753e-01, -1.3060151e00, 8.6809595e-14], "kpc" @@ -342,7 +342,7 @@ def test_spherical_to_radial(self, vector): radial = vector.represent_as(cx.RadialPosition) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) + assert jnp.array_equal(radial.r, Quantity([1, 2, 3, 4], "kpc")) @pytest.mark.filterwarnings("ignore:Irreversible dimension change") def test_spherical_to_cartesian2d(self, vector): @@ -352,13 +352,13 @@ def test_spherical_to_cartesian2d(self, vector): ) assert isinstance(cart2d, cx.CartesianPosition2D) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.x, Quantity( [1.7452406e-02, 4.9681753e-01, -1.3060151e00, 8.6809595e-14], "kpc" ), ) - assert qnp.array_equal( + assert jnp.array_equal( cart2d.y, Quantity([0.0000000e00, 1.0654287e00, 1.3060151e00, -7.2797034e-06], "kpc"), ) @@ -369,28 +369,28 @@ def test_spherical_to_polar(self, vector): polar = vector.represent_as(cx.PolarPosition, phi=Quantity([0, 1, 2, 3], "rad")) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal( + assert jnp.array_equal( polar.r, Quantity([1.7452406e-02, 1.1755705e00, 1.8469844e00, 7.2797034e-06], "kpc"), ) - assert qnp.array_equal(polar.phi, Quantity([0.0, 65.0, 135.0, 270.0], "deg")) + assert jnp.array_equal(polar.phi, Quantity([0.0, 65.0, 135.0, 270.0], "deg")) def test_spherical_to_cartesian3d(self, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" cart3d = vector.represent_as(cx.CartesianPosition3D) assert isinstance(cart3d, cx.CartesianPosition3D) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.x, Quantity( [1.7452406e-02, 4.9681753e-01, -1.3060151e00, 8.6809595e-14], "kpc" ), ) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.y, Quantity([0.0, 1.0654287e00, 1.3060151e00, -7.2797034e-06], "kpc"), ) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.z, Quantity([0.9998477, 1.618034, -2.3640323, -4.0], "kpc") ) @@ -410,12 +410,12 @@ def test_spherical_to_cylindrical(self, vector): ) assert isinstance(cyl, cx.CylindricalPosition) - assert qnp.array_equal( + assert jnp.array_equal( cyl.rho, Quantity([1.7452406e-02, 1.1755705e00, 1.8469844e00, 7.2797034e-06], "kpc"), ) - assert qnp.array_equal(cyl.phi, Quantity([0.0, 65.0, 135.0, 270.0], "deg")) - assert qnp.array_equal( + assert jnp.array_equal(cyl.phi, Quantity([0.0, 65.0, 135.0, 270.0], "deg")) + assert jnp.array_equal( cyl.z, Quantity([0.9998477, 1.618034, -2.3640323, -4.0], "kpc") ) @@ -457,9 +457,9 @@ def test_spherical_to_spherical_astropy(self, vector, apyvector): def test_spherical_to_mathspherical(self, vector): """Test ``coordinax.represent_as(MathSphericalPosition)``.""" newvec = cx.represent_as(vector, cx.MathSphericalPosition) - assert qnp.array_equal(newvec.r, vector.r) - assert qnp.array_equal(newvec.theta, vector.phi) - assert qnp.array_equal(newvec.phi, vector.theta) + assert jnp.array_equal(newvec.r, vector.r) + assert jnp.array_equal(newvec.theta, vector.phi) + assert jnp.array_equal(newvec.phi, vector.theta) def test_spherical_to_lonlatspherical(self, vector): """Test ``coordinax.represent_as(LonLatSphericalPosition)``.""" @@ -468,9 +468,9 @@ def test_spherical_to_lonlatspherical(self, vector): ) assert isinstance(llsph, cx.LonLatSphericalPosition) - assert qnp.array_equal(llsph.lon, vector.phi) - assert qnp.array_equal(llsph.lat, Quantity(90, "deg") - vector.theta) - assert qnp.array_equal(llsph.distance, vector.r) + assert jnp.array_equal(llsph.lon, vector.phi) + assert jnp.array_equal(llsph.lat, Quantity(90, "deg") - vector.theta) + assert jnp.array_equal(llsph.distance, vector.r) def test_spherical_to_lonlatspherical_astropy(self, vector, apyvector): """Test Astropy equivalence.""" @@ -535,7 +535,7 @@ def test_cartesian3d_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -544,7 +544,7 @@ def test_cartesian3d_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialPosition, vector) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -553,8 +553,8 @@ def test_cartesian3d_to_cartesian2d(self, difntl, vector): cart2d = difntl.represent_as(cx.CartesianVelocity2D, vector) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -563,8 +563,8 @@ def test_cartesian3d_to_polar(self, difntl, vector): polar = difntl.represent_as(cx.PolarPosition, vector) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) def test_cartesian3d_to_cartesian3d(self, difntl, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" @@ -592,19 +592,19 @@ def test_cartesian3d_to_spherical(self, difntl, vector): spherical = difntl.represent_as(cx.SphericalVelocity, vector) assert isinstance(spherical, cx.SphericalVelocity) - assert qnp.allclose( + assert jnp.allclose( spherical.d_r, Quantity([16.1445, 17.917269, 19.657543, 21.380898], "km/s"), atol=Quantity(1e-8, "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( spherical.d_phi, Quantity( [-0.61538464, -0.40000004, -0.275862, -0.19999999], "km rad / (kpc s)" ), atol=Quantity(1e-8, "mas/Myr"), ) - assert qnp.allclose( + assert jnp.allclose( spherical.d_theta, Quantity( [0.2052807, 0.1807012, 0.15257944, 0.12777519], "km rad / (kpc s)" @@ -628,18 +628,18 @@ def test_cartesian3d_to_cylindrical(self, difntl, vector): cylindrical = difntl.represent_as(cx.CylindricalVelocity, vector) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.array_equal( + assert jnp.array_equal( cylindrical.d_rho, Quantity([9.805806, 11.384199, 12.86803, 14.310835], "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( cylindrical.d_phi, Quantity( [-0.61538464, -0.40000004, -0.275862, -0.19999999], "km rad / (kpc s)" ), atol=Quantity(1e-8, "mas/Myr"), ) - assert qnp.array_equal( + assert jnp.array_equal( cylindrical.d_z, Quantity([13.0, 14.0, 15.0, 16], "km/s") ) @@ -696,7 +696,7 @@ def test_cylindrical_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -705,7 +705,7 @@ def test_cylindrical_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialPosition, vector) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -714,8 +714,8 @@ def test_cylindrical_to_cartesian2d(self, difntl, vector): cart2d = difntl.represent_as(cx.CartesianVelocity2D, vector) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -724,22 +724,22 @@ def test_cylindrical_to_polar(self, difntl, vector): polar = difntl.represent_as(cx.PolarPosition, vector) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) def test_cylindrical_to_cartesian3d(self, difntl, vector, apydifntl, apyvector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" cart3d = difntl.represent_as(cx.CartesianVelocity3D, vector) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.d_x, Quantity([5.0, -76.537544, -145.15944, -40.03075], "km/s") ) - assert qnp.array_equal( + assert jnp.array_equal( cart3d.d_y, Quantity([42.664234, 56.274563, -58.73506, -224.13647], "km/s"), ) - assert qnp.array_equal(cart3d.d_z, Quantity([13.0, 14.0, 15.0, 16.0], "km/s")) + assert jnp.array_equal(cart3d.d_z, Quantity([13.0, 14.0, 15.0, 16.0], "km/s")) apycart3 = apydifntl.represent_as(apyc.CartesianDifferential, apyvector) assert np.allclose(convert(cart3d.d_x, APYQuantity), apycart3.d_x) @@ -751,18 +751,18 @@ def test_cylindrical_to_spherical(self, difntl, vector): dsph = difntl.represent_as(cx.SphericalVelocity, vector) assert isinstance(dsph, cx.SphericalVelocity) - assert qnp.array_equal( + assert jnp.array_equal( dsph.d_r, Quantity([13.472646, 14.904826, 16.313278, 17.708754], "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( dsph.d_theta, Quantity( [0.3902412, 0.30769292, 0.24615361, 0.19999981], "km rad / (kpc s)" ), atol=Quantity(5e-7, "km rad / (kpc s)"), ) - assert qnp.array_equal( + assert jnp.array_equal( dsph.d_phi, Quantity([42.664234, 47.404705, 52.145176, 56.885643], "km rad / (kpc s)"), ) @@ -840,7 +840,7 @@ def test_spherical_to_cartesian1d(self, difntl, vector): cart1d = difntl.represent_as(cx.CartesianVelocity1D, vector) assert isinstance(cart1d, cx.CartesianVelocity1D) - assert qnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart1d.d_x, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -849,7 +849,7 @@ def test_spherical_to_radial(self, difntl, vector): radial = difntl.represent_as(cx.RadialPosition, vector) assert isinstance(radial, cx.RadialPosition) - assert qnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(radial.d_r, Quantity([1, 2, 3, 4], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -858,8 +858,8 @@ def test_spherical_to_cartesian2d(self, difntl, vector): cart2d = difntl.represent_as(cx.CartesianVelocity2D, vector) assert isinstance(cart2d, cx.CartesianVelocity2D) - assert qnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) + assert jnp.array_equal(cart2d.d_x, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(cart2d.d_y, Quantity([5, 6, 7, 8], "km/s")) @pytest.mark.xfail(reason="Not implemented") @pytest.mark.filterwarnings("ignore:Explicitly requested dtype") @@ -868,25 +868,25 @@ def test_spherical_to_polar(self, difntl, vector): polar = difntl.represent_as(cx.PolarPosition, vector) assert isinstance(polar, cx.PolarPosition) - assert qnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) - assert qnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) + assert jnp.array_equal(polar.d_r, Quantity([1, 2, 3, 4], "km/s")) + assert jnp.array_equal(polar.d_phi, Quantity([5, 6, 7, 8], "mas/yr")) def test_spherical_to_cartesian3d(self, difntl, vector): """Test ``coordinax.represent_as(CartesianPosition3D)``.""" cart3d = difntl.represent_as(cx.CartesianVelocity3D, vector) assert isinstance(cart3d, cx.CartesianVelocity3D) - assert qnp.allclose( + assert jnp.allclose( cart3d.d_x, Quantity([61.803337, -7.770853, -60.081947, 1.985678], "km/s"), atol=Quantity(1e-8, "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( cart3d.d_y, Quantity([2.2328734, 106.6765, -144.60716, 303.30875], "km/s"), atol=Quantity(1e-8, "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( cart3d.d_z, Quantity([1.7678856, -115.542175, -213.32118, -10.647271], "km/s"), atol=Quantity(1e-8, "km/s"), @@ -908,17 +908,17 @@ def test_spherical_to_cylindrical(self, difntl, vector): cylindrical = difntl.represent_as(cx.CylindricalVelocity, vector) assert isinstance(cylindrical, cx.CylindricalVelocity) - assert qnp.allclose( + assert jnp.allclose( cylindrical.d_rho, Quantity([61.803337, 65.60564, 6.9999905, -303.30875], "km/s"), atol=Quantity(1e-8, "km/s"), ) - assert qnp.allclose( + assert jnp.allclose( cylindrical.d_phi, Quantity([2444.4805, 2716.0894, 2987.6985, 3259.3074], "deg km / (kpc s)"), atol=Quantity(1e-8, "mas/yr"), ) - assert qnp.allclose( + assert jnp.allclose( cylindrical.d_z, Quantity([1.7678856, -115.542175, -213.32118, -10.647271], "km/s"), atol=Quantity(1e-8, "km/s"), @@ -957,9 +957,9 @@ def test_spherical_to_lonlatspherical(self, difntl, vector): llsph = difntl.represent_as(cx.LonLatSphericalVelocity, vector) assert isinstance(llsph, cx.LonLatSphericalVelocity) - assert qnp.array_equal(llsph.d_distance, difntl.d_r) - assert qnp.array_equal(llsph.d_lon, difntl.d_phi) - assert qnp.allclose( + assert jnp.array_equal(llsph.d_distance, difntl.d_r) + assert jnp.array_equal(llsph.d_lon, difntl.d_phi) + assert jnp.allclose( llsph.d_lat, Quantity([-13.0, -14.0, -15.0, -16.0], "mas/yr"), atol=Quantity(1e-8, "mas/yr"), @@ -981,6 +981,6 @@ def test_spherical_to_mathspherical(self, difntl, vector): llsph = difntl.represent_as(cx.MathSphericalVelocity, vector) assert isinstance(llsph, cx.MathSphericalVelocity) - assert qnp.array_equal(llsph.d_r, difntl.d_r) - assert qnp.array_equal(llsph.d_phi, difntl.d_theta) - assert qnp.array_equal(llsph.d_theta, difntl.d_phi) + assert jnp.array_equal(llsph.d_r, difntl.d_r) + assert jnp.array_equal(llsph.d_phi, difntl.d_theta) + assert jnp.array_equal(llsph.d_theta, difntl.d_phi)