Repository: einsteinpy/einsteinpy

Issue:
Add lorentz_tranform to all the classes in symbolic module
🐞 **Problem**
Many classes like `MetricTensor`, `RiemannCurvatureTensor` does not have the `lorentz_transform()` function as of now!

🎯 **Goal**
Implement it in a similar way as that in `GenericVector` class in `symbolic/vector.py`

  - [x] `GenericVector`
  - [ ] `MetricTensor`
  - [ ] `ChristoffelSymbols`
  - [ ] `RiemannCurvatureTensor`
  - [ ] `RicciTensor`
  - [ ] `StressEnergyMomentumTensor`
  - [x] `EinsteinTensor`
  - [ ] `WeylTensor`
  - [ ] `SchoutenTensor`

📋  **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:
codecov[bot]: # [Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@fd0429c`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368/graphs/tree.svg?width=650&token=H3oDVYA11f&height=150&src=pr)](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master     #368   +/-   ##
=========================================
  Coverage          ?   93.96%           
=========================================
  Files             ?       50           
  Lines             ?     1823           
  Branches          ?        0           
=========================================
  Hits              ?     1713           
  Misses            ?      110           
  Partials          ?        0
```


| [Impacted Files](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/einsteinpy/symbolic/einstein.py](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368/diff?src=pr&el=tree#diff-c3JjL2VpbnN0ZWlucHkvc3ltYm9saWMvZWluc3RlaW4ucHk=) | `100% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=footer). Last update [fd0429c...97ee0be](https://codecov.io/gh/einsteinpy/einsteinpy/pull/368?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

pep8speaks: Hello @michiboo! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

















* In the file [`src/einsteinpy/tests/test_symbolic/test_christoffel.py`](https://github.com/einsteinpy/einsteinpy/blob/dd4deed3dd23299acf95347c6c7ac636aa0c990e/src/einsteinpy/tests/test_symbolic/test_christoffel.py):

> [Line 102:1](https://github.com/einsteinpy/einsteinpy/blob/dd4deed3dd23299acf95347c6c7ac636aa0c990e/src/einsteinpy/tests/test_symbolic/test_christoffel.py#L102): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1



Patch:
diff --git a/src/einsteinpy/symbolic/christoffel.py b/src/einsteinpy/symbolic/christoffel.py
index 00420e1..3a19137 100644
--- a/src/einsteinpy/symbolic/christoffel.py
+++ b/src/einsteinpy/symbolic/christoffel.py
@@ -107,3 +107,23 @@ class ChristoffelSymbols(BaseRelativityTensor):
             new_tensor, self.syms, config=newconfig, parent_metric=metric
         )
         return new_obj
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.christoffel.ChristoffelSymbols
+                lorentz transformed tensor
+
+        """
+        t = super(ChristoffelSymbols, self).lorentz_transform(transformation_matrix)
+        return ChristoffelSymbols(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )
diff --git a/src/einsteinpy/symbolic/metric.py b/src/einsteinpy/symbolic/metric.py
index c96257a..2e16a82 100644
--- a/src/einsteinpy/symbolic/metric.py
+++ b/src/einsteinpy/symbolic/metric.py
@@ -63,7 +63,7 @@ class MetricTensor(BaseRelativityTensor):
         """
         if newconfig == self.config:
             return self
-        elif newconfig == "uu" or newconfig == "ll":
+        if newconfig == "uu" or newconfig == "ll":
             inv_met = MetricTensor(
                 sympy.simplify(sympy.Matrix(self.arr.tolist()).inv()).tolist(),
                 self.syms,
@@ -71,10 +71,10 @@ class MetricTensor(BaseRelativityTensor):
             )
             inv_met._invmetric = self
             return inv_met
-        else:
-            raise ValueError(
-                "Configuration can't have one upper and one lower index in Metric Tensor."
-            )
+
+        raise ValueError(
+            "Configuration can't have one upper and one lower index in Metric Tensor."
+        )
 
     def inv(self):
         """
@@ -108,3 +108,21 @@ class MetricTensor(BaseRelativityTensor):
         if self.config == "ll":
             return self
         return self.inv()
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.metric.MetricTensor
+                lorentz transformed tensor
+
+        """
+        t = super(MetricTensor, self).lorentz_transform(transformation_matrix)
+        return MetricTensor(t.tensor(), syms=self.syms, config=self._config)
diff --git a/src/einsteinpy/symbolic/ricci.py b/src/einsteinpy/symbolic/ricci.py
index c56ea1e..24d9317 100644
--- a/src/einsteinpy/symbolic/ricci.py
+++ b/src/einsteinpy/symbolic/ricci.py
@@ -140,6 +140,26 @@ class RicciTensor(BaseRelativityTensor):
         )
         return new_obj
 
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.ricci.RicciTensor
+                lorentz transformed tensor
+
+        """
+        t = super(RicciTensor, self).lorentz_transform(transformation_matrix)
+        return RicciTensor(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )
+
 
 class RicciScalar(BaseRelativityTensor):
     """
diff --git a/src/einsteinpy/symbolic/riemann.py b/src/einsteinpy/symbolic/riemann.py
index 2f111f1..19fc0a7 100644
--- a/src/einsteinpy/symbolic/riemann.py
+++ b/src/einsteinpy/symbolic/riemann.py
@@ -125,3 +125,23 @@ class RiemannCurvatureTensor(BaseRelativityTensor):
             new_tensor, self.syms, config=newconfig, parent_metric=metric
         )
         return new_obj
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.riemann.RiemannCurvatureTensor
+                lorentz transformed tensor
+
+        """
+        t = super(RiemannCurvatureTensor, self).lorentz_transform(transformation_matrix)
+        return RiemannCurvatureTensor(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )
diff --git a/src/einsteinpy/symbolic/schouten.py b/src/einsteinpy/symbolic/schouten.py
index c5a884c..89f0ad2 100644
--- a/src/einsteinpy/symbolic/schouten.py
+++ b/src/einsteinpy/symbolic/schouten.py
@@ -102,3 +102,23 @@ class SchoutenTensor(BaseRelativityTensor):
             new_tensor, self.syms, config=newconfig, parent_metric=metric
         )
         return new_obj
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.schouten.SchoutenTensor
+                lorentz transformed tensor
+
+        """
+        t = super(SchoutenTensor, self).lorentz_transform(transformation_matrix)
+        return SchoutenTensor(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )
diff --git a/src/einsteinpy/symbolic/stress_energy_momentum.py b/src/einsteinpy/symbolic/stress_energy_momentum.py
index 44739de..48a308e 100644
--- a/src/einsteinpy/symbolic/stress_energy_momentum.py
+++ b/src/einsteinpy/symbolic/stress_energy_momentum.py
@@ -87,3 +87,25 @@ class StressEnergyMomentumTensor(BaseRelativityTensor):
             new_tensor, self.syms, config=newconfig, parent_metric=metric
         )
         return new_obj
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.stress_energy_momentum.StressEnergyMomentumTensor
+                lorentz transformed tensor
+
+        """
+        t = super(StressEnergyMomentumTensor, self).lorentz_transform(
+            transformation_matrix
+        )
+        return StressEnergyMomentumTensor(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )
diff --git a/src/einsteinpy/symbolic/weyl.py b/src/einsteinpy/symbolic/weyl.py
index 35447e7..58900ca 100644
--- a/src/einsteinpy/symbolic/weyl.py
+++ b/src/einsteinpy/symbolic/weyl.py
@@ -96,7 +96,7 @@ class WeylTensor(BaseRelativityTensor):
                 )
             C = sympy.simplify(sympy.Array(C))
             return cls(C, metric.syms, config="llll", parent_metric=metric)
-        elif metric.dims == 3:
+        if metric.dims == 3:
             return cls(
                 sympy.Array(np.zeros((3, 3), dtype=int)),
                 metric.syms,
@@ -138,3 +138,23 @@ class WeylTensor(BaseRelativityTensor):
             new_tensor, self.syms, config=newconfig, parent_metric=metric
         )
         return new_obj
+
+    def lorentz_transform(self, transformation_matrix):
+        """
+        Performs a Lorentz transform on the tensor.
+
+        Parameters
+        ----------
+            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+                Sympy Array or multi-dimensional list containing Sympy Expressions
+
+        Returns
+        -------
+            ~einsteinpy.symbolic.weyl.WeylTensor
+                lorentz transformed tensor(or vector)
+
+        """
+        t = super(WeylTensor, self).lorentz_transform(transformation_matrix)
+        return WeylTensor(
+            t.tensor(), syms=self.syms, config=self._config, parent_metric=None,
+        )


Test patch:
diff --git a/src/einsteinpy/tests/test_symbolic/test_christoffel.py b/src/einsteinpy/tests/test_symbolic/test_christoffel.py
index fd9018d..82a7354 100644
--- a/src/einsteinpy/tests/test_symbolic/test_christoffel.py
+++ b/src/einsteinpy/tests/test_symbolic/test_christoffel.py
@@ -1,7 +1,9 @@
 import numpy as np
 import sympy
+from sympy import cosh, sinh, symbols
 
 from einsteinpy.symbolic import ChristoffelSymbols, MetricTensor
+from einsteinpy.symbolic.predefined import AntiDeSitter
 
 
 def schwarzschild_metric():
@@ -98,3 +100,27 @@ def test_properties():
         assert False
     except Exception:
         return True
+
+
+def test_lorentz_transform():
+    # currently testing correct instance, proper theoretical tests needed
+    def get_lorentz_matrix():
+        list2d = [[0 for t1 in range(4)] for t2 in range(4)]
+        phi = symbols("phi")
+        list2d[0][0], list2d[0][1], list2d[1][0], list2d[1][1] = (
+            cosh(phi),
+            -sinh(phi),
+            -sinh(phi),
+            cosh(phi),
+        )
+        list2d[2][2], list2d[3][3] = 1, 1
+        return list2d
+
+    def get_tensor():
+        metric = AntiDeSitter()
+        return ChristoffelSymbols.from_metric(metric)
+
+    tm = get_lorentz_matrix()
+    t0 = get_tensor()
+    t1 = t0.lorentz_transform(tm)
+    assert isinstance(t1, ChristoffelSymbols)