Repository: einsteinpy/einsteinpy

Issue:
Clean the Messed up utils!
🐞 **Problem**

The `utils` module is currently too messed up. 

🎯 **Goal**

<!--- Why is this change important to you? How would you use it? -->
<!--- How can it benefit other users? -->

💡 **Possible solutions**

Make necessary changes to clean it. Refactor modules, code.
<!--- Not obligatory, but suggest an idea for implementing addition or change -->

📋  **Steps to solve the problem**

 * Comment below about what you've started working on.
 * Add, commit, push your changes
 * Submit a pull request and add this in comments - `Addresses #<put issue number here>`
 * Ask for a review in comments section of pull request
 * Celebrate your contribution to this project 🎉


Discussion:
rishi-s8: Thanks for reviewing. I will do these changes :)
shreyasbapat: Thanks a lot for the efforts! :)

Patch:
diff --git a/docs/source/api/coordinates/coordinates_index.rst b/docs/source/api/coordinates/coordinates_index.rst
new file mode 100644
index 0000000..7918c8f
--- /dev/null
+++ b/docs/source/api/coordinates/coordinates_index.rst
@@ -0,0 +1,11 @@
+Coordinates module
+==================
+
+This module contains the classes for various coordinate
+systems and their position and velocity transformations.
+
+.. toctree::
+    :maxdepth: 2
+
+    core
+    velocity
diff --git a/docs/source/api/coordinates/core.rst b/docs/source/api/coordinates/core.rst
new file mode 100644
index 0000000..aac6adf
--- /dev/null
+++ b/docs/source/api/coordinates/core.rst
@@ -0,0 +1,7 @@
+core module
+===========
+
+This module contains the basic classes for coordinate systems and their position transformation:
+
+.. automodule:: einsteinpy.coordinates.core
+    :members:
diff --git a/docs/source/api/coordinates/velocity.rst b/docs/source/api/coordinates/velocity.rst
new file mode 100644
index 0000000..441c134
--- /dev/null
+++ b/docs/source/api/coordinates/velocity.rst
@@ -0,0 +1,7 @@
+velocity module
+===============
+
+This module contains the basic classes for time differentials of coordinate systems and the transformations:
+
+.. automodule:: einsteinpy.coordinates.velocity
+    :members:
diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst
index 249c044..fbe8a83 100644
--- a/docs/source/api/index.rst
+++ b/docs/source/api/index.rst
@@ -1,10 +1,15 @@
 EinsteinPy API
 ==============
 
+Welcome to the API documenatation of EinsteinPy. Please navigate through the given modules to get to
+know the API of the classes and methods. If you find anything missing, please open an `issue in the repo`_ .
+
+.. _`issue in the repo` : https://github.com/einsteinpy/einsteinpy
+
 .. graphviz::
 
     digraph {
-        "einsteinpy" -> "integrators", "metric", "utils", "plotting", "constant", "units"
+        "einsteinpy" -> "integrators", "metric", "utils", "plotting", "constant", "units", "coordinates"
 
     }
 
@@ -16,5 +21,6 @@ EinsteinPy API
     metric/metric_index
     utils/utils_index
     plotting/plotting_index
+    coordinates/coordinates_index
     constant
     units
diff --git a/src/einsteinpy/coordinates/__init__.py b/src/einsteinpy/coordinates/__init__.py
new file mode 100644
index 0000000..3c677fd
--- /dev/null
+++ b/src/einsteinpy/coordinates/__init__.py
@@ -0,0 +1,7 @@
+from einsteinpy.coordinates.core import BoyerLindquist, Cartesian, Spherical
+
+from einsteinpy.coordinates.velocity import (  # isort:skip
+    BoyerLindquistDifferential,
+    CartesianDifferential,
+    SphericalDifferential,
+)  # isort: skip added because isort and black conflict on the above import, to be fixed later
diff --git a/src/einsteinpy/coordinates/core.py b/src/einsteinpy/coordinates/core.py
new file mode 100644
index 0000000..83a9de3
--- /dev/null
+++ b/src/einsteinpy/coordinates/core.py
@@ -0,0 +1,225 @@
+import astropy.units as u
+import numpy as np
+
+
+class Cartesian:
+    """
+    Class for Cartesian Coordinates and related transformations.
+    """
+
+    @u.quantity_input(x=u.km, y=u.km, z=u.km)
+    def __init__(self, x, y, z):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        x : ~astropy.units
+        y : ~astropy.units
+        z : ~astropy.units
+        """
+        self.x = x
+        self.y = y
+        self.z = z
+
+    def norm(self):
+        """
+        Function for finding euclidean norm of a vector.
+
+        Returns
+        -------
+        distance : ~astropy.units
+            Euclidean norm with units.
+
+        """
+        o = Cartesian(0 * u.km, 0 * u.km, 0 * u.km)
+
+        x = self.x - o.x
+        y = self.y - o.y
+        z = self.z - o.z
+
+        sq = x ** 2 + y ** 2 + z ** 2
+
+        distance = sq ** 0.5
+
+        return distance
+
+    def dot(self, target):
+        """
+        Dot product of two vectors.
+
+        Parameters
+        ----------
+        target: ~einsteipy.coordinates.core.Cartesian
+
+        Returns
+        -------
+        dotproduct : ~astropy.units
+            Dot product with units
+
+        """
+
+        x = self.x * target.x
+        y = self.y * target.y
+        z = self.z * target.z
+
+        return x + y + z
+
+    def to_spherical(self):
+        """
+        Method for conversion to spherical coordinates.
+
+        Returns
+        -------
+        spherical : ~einsteinpy.coordinates.core.Spherical
+            Spherical representation of the Cartesian Coordinates.
+
+        """
+        r = self.norm()
+        theta = np.arccos(self.z / r)
+        phi = np.arctan2(self.y, self.x)
+
+        return Spherical(r, theta, phi)
+
+    @u.quantity_input(a=u.km)
+    def to_bl(self, a):
+        """
+        Method for conversion to boyer-lindquist coordinates.
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        bl : ~einsteinpy.coordinates.core.BoyerLindquist
+            BL representation of the Cartesian Coordinates.
+
+        """
+        w = self.norm() ** 2 - a ** 2
+        r = np.sqrt(0.5 * (w + np.sqrt((w ** 2) + (4 * (a ** 2) * (self.z ** 2)))))
+        theta = np.arccos(self.z / r)
+        phi = np.arctan2(self.y, self.x)
+
+        return BoyerLindquist(r, theta, phi)
+
+
+class Spherical:
+    """
+    Class for Spherical Coordinates and related transformations.
+    """
+
+    @u.quantity_input(r=u.km, theta=u.rad, phi=u.rad)
+    def __init__(self, r, theta, phi):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        r : ~astropy.units
+        theta : ~astropy.units
+        phi : ~astropy.units
+        """
+        self.r = r
+        self.theta = theta
+        self.phi = phi
+
+    def to_cartesian(self):
+        """
+        Method for conversion to cartesian coordinates.
+
+        Returns
+        -------
+        cartesian : ~einsteinpy.coordinates.core.Cartesian
+            Cartesian representation of the Spherical Coordinates.
+
+        """
+        x = self.r * np.cos(self.phi) * np.sin(self.theta)
+        y = self.r * np.sin(self.phi) * np.sin(self.theta)
+        z = self.r * np.cos(self.theta)
+
+        return Cartesian(x, y, z)
+
+    @u.quantity_input(a=u.km)
+    def to_bl(self, a):
+        """
+        Method for conversion to boyer-lindquist coordinates.
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        bl : ~einsteinpy.coordinates.core.BoyerLindquist
+            BL representation of the Spherical Coordinates.
+
+        """
+        cart = self.to_cartesian()
+        bl = cart.to_bl(a)
+        return bl
+
+
+class BoyerLindquist:
+    """
+    Class for Spherical Coordinates and related transformations.
+    """
+
+    @u.quantity_input(r=u.km, theta=u.rad, phi=u.rad)
+    def __init__(self, r, theta, phi):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        r : ~astropy.units
+        theta : ~astropy.units
+        phi : ~astropy.units
+        """
+        self.r = r
+        self.theta = theta
+        self.phi = phi
+
+    @u.quantity_input(a=u.km)
+    def to_cartesian(self, a):
+        """
+        Method for conversion to cartesian coordinates.
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        bl : ~einsteinpy.coordinates.core.Cartesian
+            Cartesian representation of the BL Coordinates.
+
+        """
+        sin_norm = np.sqrt(self.r ** 2 + a ** 2) * np.sin(self.theta)
+        x = sin_norm * np.cos(self.phi)
+        y = sin_norm * np.sin(self.phi)
+        z = self.r * np.cos(self.theta)
+        return Cartesian(x, y, z)
+
+    @u.quantity_input(a=u.km)
+    def to_spherical(self, a):
+        """
+        Method for conversion to spherical coordinates.
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        spherical : ~einsteinpy.coordinates.core.Spherical
+            Spherical representation of the BL Coordinates.
+
+        """
+        cart = self.to_cartesian(a)
+        spherical = cart.to_spherical()
+        return spherical
diff --git a/src/einsteinpy/coordinates/velocity.py b/src/einsteinpy/coordinates/velocity.py
new file mode 100644
index 0000000..c8e0cb4
--- /dev/null
+++ b/src/einsteinpy/coordinates/velocity.py
@@ -0,0 +1,258 @@
+import astropy.units as u
+import numpy as np
+
+from einsteinpy.coordinates import BoyerLindquist, Cartesian, Spherical
+
+
+class CartesianDifferential(Cartesian):
+    """
+    Class for calculating and transforming the velocity
+    """
+
+    @u.quantity_input(
+        x=u.km, y=u.km, z=u.km, v_x=u.km / u.s, v_y=u.km / u.s, v_z=u.km / u.s
+    )
+    def __init__(self, x, y, z, v_x, v_y, v_z):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        x : ~astropy.units
+        y : ~astropy.units
+        z : ~astropy.units
+        v_x : ~astropy.units
+        v_y : ~astropy.units
+        v_z : ~astropy.units
+        """
+        super(CartesianDifferential, self).__init__(x, y, z)
+        self.v_x = v_x
+        self.v_y = v_y
+        self.v_z = v_z
+
+    def spherical_differential(self):
+        """
+        Function to convert velocity to spherical coordinates
+
+        Returns
+        -------
+        SphericalDifferential : ~einsteinpy.coordinates.velocity.SphericalDifferential
+            Spherical representation of the velocity in Cartesian Coordinates.
+
+        """
+        transformed_spherical = self.to_spherical()
+        n1 = self.x ** 2 + self.y ** 2
+        n2 = n1 + self.z ** 2
+        v_r = (self.x * self.v_x + self.y * self.v_y + self.z * self.v_z) / np.sqrt(n2)
+
+        v_t = (
+            (self.z * (self.x * self.v_x + self.y * self.v_y) - n1 * self.v_z)
+            / (n2 * np.sqrt(n1))
+            * u.rad
+        )
+
+        v_p = (-1 * (self.v_x * self.y - self.x * self.v_y) / n1) * u.rad
+        return SphericalDifferential(
+            transformed_spherical.r,
+            transformed_spherical.theta,
+            transformed_spherical.phi,
+            v_r,
+            v_t,
+            v_p,
+        )
+
+    @u.quantity_input(a=u.km)
+    def bl_differential(self, a):
+        """
+        Function to convert velocity to Boyer-Lindquist coordinates
+
+        Returns
+        -------
+        BoyerLindquistDifferential : ~einsteinpy.coordinates.velocity.BoyerLindquistDifferential
+            Boyer-Lindquist representation of the velocity in Cartesian Coordinates.
+
+        """
+        transformed_bl = self.to_bl(a)
+        w = (self.x ** 2 + self.y ** 2 + self.z ** 2) - (a ** 2)
+        dw_dt = 2 * (self.x * self.v_x + self.y * self.v_y + self.z * self.v_z)
+        v_r = (1 / (2 * transformed_bl.r)) * (
+            (dw_dt / 2)
+            + (
+                (w * dw_dt + 4 * (a ** 2) * self.z * self.v_z)
+                / (2 * np.sqrt((w ** 2) + (4 * (a ** 2) * (self.z ** 2))))
+            )
+        )
+        v_t = (
+            (-1 / np.sqrt(1 - np.square(self.z / transformed_bl.r)))
+            * ((self.v_z * transformed_bl.r - v_r * self.z) / (transformed_bl.r ** 2))
+            * u.rad
+        )
+        v_p = (
+            (1 / (1 + np.square(self.y / self.x)))
+            * ((self.v_y * self.x - self.v_x * self.y) / (self.x ** 2))
+            * u.rad
+        )
+        return BoyerLindquistDifferential(
+            transformed_bl.r, transformed_bl.theta, transformed_bl.phi, v_r, v_t, v_p
+        )
+
+
+class SphericalDifferential(Spherical):
+    """
+    Class for calculating and transforming the velocity
+    """
+
+    @u.quantity_input(
+        r=u.km, theta=u.rad, phi=u.rad, v_r=u.km / u.s, v_t=u.rad / u.s, v_p=u.rad / u.s
+    )
+    def __init__(self, r, theta, phi, v_r, v_t, v_p):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        r : ~astropy.units
+        theta : ~astropy.units
+        phi : ~astropy.units
+        v_r : ~astropy.units
+        v_t : ~astropy.units
+        v_p : ~astropy.units
+        """
+        super(SphericalDifferential, self).__init__(r, theta, phi)
+        self.v_r = v_r
+        self.v_t = v_t
+        self.v_p = v_p
+
+    def cartesian_differential(self):
+        """
+        Function to convert velocity to cartesian coordinates
+
+        Returns
+        -------
+        CartesianDifferential : ~einsteinpy.coordinates.velocity.CartesianDifferential
+            Cartesian representation of the velocity in Spherical Coordinates.
+
+        """
+        transformed_cartesian = self.to_cartesian()
+        v_x = (
+            np.sin(self.theta) * np.cos(self.phi) * self.v_r
+            - self.r * np.sin(self.theta) * np.sin(self.phi) * self.v_p / u.rad
+            + self.r * np.cos(self.theta) * np.cos(self.phi) * self.v_t / u.rad
+        )
+        v_y = (
+            np.sin(self.theta) * np.sin(self.phi) * self.v_r
+            + self.r * np.cos(self.theta) * np.sin(self.phi) * self.v_t / u.rad
+            + self.r * np.sin(self.theta) * np.cos(self.phi) * self.v_p / u.rad
+        )
+        v_z = (
+            np.cos(self.theta) * self.v_r
+            - self.r * np.sin(self.theta) * self.v_t / u.rad
+        )
+        return CartesianDifferential(
+            transformed_cartesian.x,
+            transformed_cartesian.y,
+            transformed_cartesian.z,
+            v_x,
+            v_y,
+            v_z,
+        )
+
+    @u.quantity_input(a=u.km)
+    def bl_differential(self, a):
+        """
+        Function to convert velocity to Boyer-Lindquist coordinates
+
+        Returns
+        -------
+        BoyerLindquistDifferential : ~einsteinpy.coordinates.velocity.BoyerLindquistDifferential
+            Boyer-Lindquist representation of the velocity in Spherical Coordinates.
+
+        """
+        transformed_cartesian = self.cartesian_differential()
+        return transformed_cartesian.bl_differential(a)
+
+
+class BoyerLindquistDifferential(BoyerLindquist):
+    """
+    Class for calculating and transforming the velocity
+    """
+
+    @u.quantity_input(
+        r=u.km, theta=u.rad, phi=u.rad, v_r=u.km / u.s, v_t=u.rad / u.s, v_p=u.rad / u.s
+    )
+    def __init__(self, r, theta, phi, v_r, v_t, v_p):
+        """
+        Constructor.
+
+        Parameters
+        ----------
+        r : ~astropy.units
+        theta : ~astropy.units
+        phi : ~astropy.units
+        v_r : ~astropy.units
+        v_t : ~astropy.units
+        v_p : ~astropy.units
+        """
+        super(BoyerLindquistDifferential, self).__init__(r, theta, phi)
+        self.v_r = v_r
+        self.v_t = v_t
+        self.v_p = v_p
+
+    @u.quantity_input(a=u.km)
+    def cartesian_differential(self, a):
+        """
+        Function to convert velocity to cartesian coordinates
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        CartesianDifferential : ~einsteinpy.coordinates.velocity.CartesianDifferential
+            Cartesian representation of the velocity in Boyer-Lindquist Coordinates.
+
+        """
+        transformed_cartesian = self.to_cartesian(a)
+        xa = np.sqrt(self.r ** 2 + a ** 2)
+        v_x = (
+            (self.r * self.v_r * np.sin(self.theta) * np.cos(self.phi) / xa)
+            + (xa * np.cos(self.theta) * np.cos(self.phi) * self.v_t / u.rad)
+            - (xa * np.sin(self.theta) * np.sin(self.phi) * self.v_p / u.rad)
+        )
+        v_y = (
+            (self.r * self.v_r * np.sin(self.theta) * np.sin(self.phi) / xa)
+            + (xa * np.cos(self.theta) * np.sin(self.phi) * self.v_t / u.rad)
+            + (xa * np.sin(self.theta) * np.cos(self.phi) * self.v_p / u.rad)
+        )
+        v_z = (self.v_r * np.cos(self.theta)) - (
+            self.r * np.sin(self.theta) * self.v_t / u.rad
+        )
+        return CartesianDifferential(
+            transformed_cartesian.x,
+            transformed_cartesian.y,
+            transformed_cartesian.z,
+            v_x,
+            v_y,
+            v_z,
+        )
+
+    @u.quantity_input(a=u.km)
+    def spherical_differential(self, a):
+        """
+        Function to convert velocity to spherical coordinates
+
+        Parameters
+        ----------
+        a : float
+             a = J/M , the angular momentum per unit mass of the black hole.
+
+        Returns
+        -------
+        SphericalDifferential : ~einsteinpy.coordinates.velocity.SphericalDifferential
+            Spherical representation of the velocity in Boyer-Lindquist Coordinates.
+
+        """
+        transformed_cartesian = self.cartesian_differential(a)
+        return transformed_cartesian.spherical_differential()
diff --git a/src/einsteinpy/utils/bl_coord_transforms.py b/src/einsteinpy/utils/bl_coord_transforms.py
index 730378e..8daadc7 100644
--- a/src/einsteinpy/utils/bl_coord_transforms.py
+++ b/src/einsteinpy/utils/bl_coord_transforms.py
@@ -1,6 +1,12 @@
+import warnings
+
 import astropy.units as u
 import numpy as np
 
+warnings.warn(
+    "This module will be deprecated in EinsteinPy v0.3.0. Please switch to `einsteinpy.coordinates`."
+)
+
 
 def CartesianToBL_pos(pos_vec, a):
     """
@@ -46,7 +52,7 @@ def CartesianToBL_vel(pos_vec, vel_vec, a):
     -------
     ~numpy.array
         3-length numpy array having v_r, v_theta, v_phi in (m/s, rad/s, rad/s)
-    
+
     """
     v_vec = np.zeros(shape=(3,), dtype=float)
     w = float(np.sum(np.square(pos_vec[:3])) - (a ** 2))
@@ -219,7 +225,7 @@ def BL2C_8dim(vec, a):
     -------
     ~numpy.array
         Array of shape (n,8) in the form [t,x,y,z,vt,vx,vy,vz] in SI units
-        
+
     """
 
     newvec = np.copy(vec)
diff --git a/src/einsteinpy/utils/coord_transforms.py b/src/einsteinpy/utils/coord_transforms.py
index 7bec57c..1b8ecc0 100644
--- a/src/einsteinpy/utils/coord_transforms.py
+++ b/src/einsteinpy/utils/coord_transforms.py
@@ -1,6 +1,12 @@
+import warnings
+
 import astropy.units as u
 import numpy as np
 
+warnings.warn(
+    "This module will be deprecated in EinsteinPy v0.3.0. Please switch to `einsteinpy.coordinates`."
+)
+
 
 def CartesianToSpherical_pos(pos_vec):
     """
@@ -10,7 +16,7 @@ def CartesianToSpherical_pos(pos_vec):
     ----------
     pos_vec : ~numpy.array
         3-length numpy array having x,y,z coordinates in SI units(m)
-    
+
     Returns
     -------
     ~numpy.array
@@ -63,7 +69,7 @@ def SphericalToCartesian_pos(pos_vec):
     ----------
     pos_vec : ~numpy.array
         3-length numpy array having r, theta, phi coordinates in SI units(m, rad, rad)
-    
+
     Returns
     -------
     ~numpy.array
@@ -194,7 +200,7 @@ def S2C_8dim(vec):
     -------
     ~numpy.array
         Array of shape (n,8) in the form [t,x,y,z,vt,vx,vy,vz] in SI units
-        
+
     """
 
     newvec = np.copy(vec)


Test patch:
diff --git a/src/einsteinpy/tests/test_coordinates/test_coord_transform.py b/src/einsteinpy/tests/test_coordinates/test_coord_transform.py
new file mode 100644
index 0000000..fdf82f0
--- /dev/null
+++ b/src/einsteinpy/tests/test_coordinates/test_coord_transform.py
@@ -0,0 +1,78 @@
+import astropy.units as u
+import pytest
+
+from einsteinpy import coordinates
+
+
+@pytest.fixture()
+def cartesian():
+    return coordinates.Cartesian(20.0 * u.km, 311.0 * u.km, 210.0 * u.km)
+
+
+@pytest.fixture()
+def spherical():
+    return coordinates.Spherical(
+        375.79382645275 * u.km, 0.9778376650369 * u.rad, 1.5065760775947 * u.rad
+    )
+
+
+@pytest.fixture()
+def boyerlindquist():
+    return (
+        coordinates.BoyerLindquist(
+            375.79382645275 * u.km, 0.9778376650369 * u.rad, 1.5065760775947 * u.rad
+        ),
+        0.0 * u.km,
+    )
+
+
+def assert_cartesian(cartesian, to_cartesian):
+    assert abs(to_cartesian.x - cartesian.x) <= (1e-5) * u.km
+    assert abs(to_cartesian.y - cartesian.y) <= (1e-5) * u.km
+    assert abs(to_cartesian.z - cartesian.z) <= (1e-5) * u.km
+
+
+def assert_spherical(spherical, to_spherical):
+    assert abs(to_spherical.r - spherical.r) <= (1e-5) * u.km
+    assert abs(to_spherical.theta - spherical.theta) <= (1e-5) * u.rad
+    assert abs(to_spherical.phi - spherical.phi) <= (1e-5) * u.rad
+
+
+def assert_boyerlindquist(bl, to_bl):
+    assert abs(to_bl.r - bl.r) <= (1e-5) * u.km
+    assert abs(to_bl.theta - bl.theta) <= (1e-5) * u.rad
+    assert abs(to_bl.phi - bl.phi) <= (1e-5) * u.rad
+
+
+def test_CartesianToSpherical(cartesian, spherical):
+    to_spherical = cartesian.to_spherical()
+    assert_spherical(spherical, to_spherical)
+
+
+def test_CartesianToBoyerLindquist(cartesian, boyerlindquist):
+    bl, a = boyerlindquist
+    to_bl = cartesian.to_bl(a)
+    assert_boyerlindquist(bl, to_bl)
+
+
+def test_SphericalToCartesian(spherical, cartesian):
+    to_cartesian = spherical.to_cartesian()
+    assert_cartesian(cartesian, to_cartesian)
+
+
+def test_SphericalToBoyerLindquist(spherical, boyerlindquist):
+    bl, a = boyerlindquist
+    to_bl = spherical.to_bl(a)
+    assert_boyerlindquist(bl, to_bl)
+
+
+def test_BoyerLindquistToCartesian(boyerlindquist, cartesian):
+    bl, a = boyerlindquist
+    to_cartesian = bl.to_cartesian(a)
+    assert_cartesian(cartesian, to_cartesian)
+
+
+def test_BoyerLindquistToSpherical(boyerlindquist, spherical):
+    bl, a = boyerlindquist
+    to_spherical = bl.to_spherical(a)
+    assert_spherical(spherical, to_spherical)
diff --git a/src/einsteinpy/tests/test_coordinates/test_velocity_transform.py b/src/einsteinpy/tests/test_coordinates/test_velocity_transform.py
new file mode 100644
index 0000000..a30c7df
--- /dev/null
+++ b/src/einsteinpy/tests/test_coordinates/test_velocity_transform.py
@@ -0,0 +1,150 @@
+import astropy.units as u
+import numpy as np
+import pytest
+
+from einsteinpy import coordinates
+
+
+@pytest.fixture()
+def cartesian_differential():
+    return coordinates.CartesianDifferential(
+        10 / np.sqrt(2) * u.km,
+        10 / np.sqrt(2) * u.km,
+        0 * u.km,
+        -190 / np.sqrt(2) * u.km / u.s,
+        210 / np.sqrt(2) * u.km / u.s,
+        200.0 * u.km / u.s,
+    )
+
+
+@pytest.fixture()
+def spherical_differential():
+    return coordinates.SphericalDifferential(
+        10.0 * u.km,
+        1.5707963267948966 * u.rad,
+        0.7853981633974483 * u.rad,
+        10.0 * u.km / u.s,
+        -20.0 * u.rad / u.s,
+        20.0 * u.rad / u.s,
+    )
+
+
+@pytest.fixture()
+def bl_differential():
+    return (
+        coordinates.BoyerLindquistDifferential(
+            10.0 * u.km,
+            1.5707963267948966 * u.rad,
+            0.7853981633974483 * u.rad,
+            10.0 * u.km / u.s,
+            -20.0 * u.rad / u.s,
+            20.0 * u.rad / u.s,
+        ),
+        0.0 * u.km,
+    )
+
+
+def assert_cartesian_pos(cartesian_differential, to_cartesian_differential):
+    assert abs(to_cartesian_differential.y - cartesian_differential.y) <= (1e-5) * u.km
+    assert abs(to_cartesian_differential.z - cartesian_differential.z) <= (1e-5) * u.km
+    assert (
+        abs(to_cartesian_differential.v_x - cartesian_differential.v_x)
+        <= (1e-5) * u.km / u.s
+    )
+
+
+def assert_cartesian_differential(cartesian_differential, to_cartesian_differential):
+    assert abs(to_cartesian_differential.x - cartesian_differential.x) <= (1e-5) * u.km
+
+    assert (
+        abs(to_cartesian_differential.v_y - cartesian_differential.v_y)
+        <= (1e-5) * u.km / u.s
+    )
+    assert (
+        abs(to_cartesian_differential.v_z - cartesian_differential.v_z)
+        <= (1e-5) * u.km / u.s
+    )
+
+
+def assert_spherical_pos(spherical_differential, to_spherical_differential):
+    assert abs(to_spherical_differential.r - spherical_differential.r) <= (1e-5) * u.km
+    assert (
+        abs(to_spherical_differential.theta - spherical_differential.theta)
+        <= (1e-5) * u.rad
+    )
+    assert (
+        abs(to_spherical_differential.phi - spherical_differential.phi)
+        <= (1e-5) * u.rad
+    )
+
+
+def assert_spherical_differential(spherical_differential, to_spherical_differential):
+    assert (
+        abs(to_spherical_differential.v_r - spherical_differential.v_r)
+        <= (1e-5) * u.km / u.s
+    )
+    assert (
+        abs(to_spherical_differential.v_t - spherical_differential.v_t)
+        <= (1e-5) * u.rad / u.s
+    )
+    assert (
+        abs(to_spherical_differential.v_p - spherical_differential.v_p)
+        <= (1e-5) * u.rad / u.s
+    )
+
+
+def assert_boyerlindquist_pos(bl_differential, to_bl_differential):
+    assert abs(to_bl_differential.r - bl_differential.r) <= (1e-5) * u.km
+    assert abs(to_bl_differential.theta - bl_differential.theta) <= (1e-5) * u.rad
+    assert abs(to_bl_differential.phi - bl_differential.phi) <= (1e-5) * u.rad
+
+
+def assert_bl_differential(bl_differential, to_bl_differential):
+
+    assert abs(to_bl_differential.v_r - bl_differential.v_r) <= (1e-5) * u.km / u.s
+    assert abs(to_bl_differential.v_t - bl_differential.v_t) <= (1e-5) * u.rad / u.s
+    assert abs(to_bl_differential.v_p - bl_differential.v_p) <= (1e-5) * u.rad / u.s
+
+
+def test_CartesianToSphericalDifferential(
+    cartesian_differential, spherical_differential
+):
+    to_spherical_differential = cartesian_differential.spherical_differential()
+    assert_spherical_pos(spherical_differential, to_spherical_differential)
+    assert_spherical_differential(spherical_differential, to_spherical_differential)
+
+
+def test_CartesianToBoyerLindquistDifferential(cartesian_differential, bl_differential):
+    bl_differential, a = bl_differential
+    to_bl_differential = cartesian_differential.bl_differential(a)
+    assert_boyerlindquist_pos(bl_differential, to_bl_differential)
+    assert_bl_differential(bl_differential, to_bl_differential)
+
+
+def test_SphericalToCartesianDifferential(
+    spherical_differential, cartesian_differential
+):
+    to_cartesian_differential = spherical_differential.cartesian_differential()
+    assert_cartesian_pos(cartesian_differential, to_cartesian_differential)
+    assert_cartesian_differential(cartesian_differential, to_cartesian_differential)
+
+
+def test_SphericalToBoyerLindquistDifferential(spherical_differential, bl_differential):
+    bl_differential, a = bl_differential
+    to_bl_differential = spherical_differential.bl_differential(a)
+    assert_boyerlindquist_pos(bl_differential, to_bl_differential)
+    assert_bl_differential(bl_differential, to_bl_differential)
+
+
+def test_BoyerLindquistToCartesianDifferential(bl_differential, cartesian_differential):
+    bl_differential, a = bl_differential
+    to_cartesian_differential = bl_differential.cartesian_differential(a)
+    assert_cartesian_pos(cartesian_differential, to_cartesian_differential)
+    assert_cartesian_differential(cartesian_differential, to_cartesian_differential)
+
+
+def test_BoyerLindquistToSphericalDifferential(bl_differential, spherical_differential):
+    bl_differential, a = bl_differential
+    to_spherical_differential = bl_differential.spherical_differential(a)
+    assert_spherical_pos(spherical_differential, to_spherical_differential)
+    assert_spherical_differential(spherical_differential, to_spherical_differential)