@@ -0,0 +1,1248 @@
+# coding: utf-8%0A%0A%22%22%22 Test utils. %22%22%22%0A%0Afrom __future__ import division, print_function%0A%0A__author__ = %22adrn %3Cadrn@astro.columbia.edu%3E%22%0A%0A# Standard library%0Aimport os, sys%0A%0A# Third-party%0Aimport numpy as np%0Aimport pytest%0Afrom astropy import log as logger%0Aimport astropy.units as u%0A%0A# Project%0Afrom ..util import cartesian_to_spherical, spherical_to_cartesian%0A%0Adef test_roundtrip():%0A    n = 1000%0A%0A    # cartesian -%3E spherical -%3E cartesian%0A    x = np.random.uniform(-100,100,size=(n,3))%0A    v = np.random.uniform(-1,1,size=(n,3))%0A%0A    sph = cartesian_to_spherical(x, v)%0A    xp,vp = spherical_to_cartesian(*sph.T)%0A%0A    assert np.allclose(x, xp)%0A    assert np.allclose(v, vp)%0A%0A    # spherical -%3E cartesian -%3E spherical%0A    r = np.random.uniform(0.1,100,size=n)%0A    phi = np.random.uniform(0.,2*np.pi,size=n)%0A    theta = np.arccos(2*np.random.uniform(0.,1,size=n) - 1)%0A    vr,vphi,vtheta = np.random.uniform(-1,1,size=(3,n))%0A%0A    x,v = spherical_to_cartesian(r,phi,theta,vr,vphi,vtheta)%0A    sph = cartesian_to_spherical(x, v)%0A%0A    assert np.allclose(r, sph%5B:,0%5D)%0A    assert np.allclose(phi, sph%5B:,1%5D)%0A    assert np.allclose(theta, sph%5B:,2%5D)%0A    assert np.allclose(vr, sph%5B:,3%5D)%0A    assert np.allclose(vphi, sph%5B:,4%5D)%0A    assert np.allclose(vtheta, sph%5B:,5%5D)%0A%0A

add test for spherical / cartesian