codecov[bot]: # [Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=h1) Report
> Merging [#322](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=desc) into [master](https://codecov.io/gh/einsteinpy/einsteinpy/commit/32d3c476f849761798037b3e325fef5b6c8fb30d?src=pr&el=desc) will **decrease** coverage by `0.08%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master     #322      +/-   ##
==========================================
- Coverage   94.06%   93.97%   -0.09%     
==========================================
  Files          38       38              
  Lines        1482     1460      -22     
==========================================
- Hits         1394     1372      -22     
  Misses         88       88
```


| [Impacted Files](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/einsteinpy/symbolic/tensor.py](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322/diff?src=pr&el=tree#diff-c3JjL2VpbnN0ZWlucHkvc3ltYm9saWMvdGVuc29yLnB5) | `96.84% <100%> (-1.01%)` | :arrow_down: |
| [src/einsteinpy/plotting/geodesics/static.py](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322/diff?src=pr&el=tree#diff-c3JjL2VpbnN0ZWlucHkvcGxvdHRpbmcvZ2VvZGVzaWNzL3N0YXRpYy5weQ==) | `100% <0%> (+1.11%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?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/322?src=pr&el=footer). Last update [32d3c47...c1adefb](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

codecov[bot]: # [Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=h1) Report
> Merging [#322](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=desc) into [master](https://codecov.io/gh/einsteinpy/einsteinpy/commit/32d3c476f849761798037b3e325fef5b6c8fb30d?src=pr&el=desc) will **decrease** coverage by `0.08%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master     #322      +/-   ##
==========================================
- Coverage   94.06%   93.97%   -0.09%     
==========================================
  Files          38       38              
  Lines        1482     1460      -22     
==========================================
- Hits         1394     1372      -22     
  Misses         88       88
```


| [Impacted Files](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/einsteinpy/symbolic/tensor.py](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322/diff?src=pr&el=tree#diff-c3JjL2VpbnN0ZWlucHkvc3ltYm9saWMvdGVuc29yLnB5) | `96.84% <100%> (-1.01%)` | :arrow_down: |
| [src/einsteinpy/plotting/geodesics/static.py](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322/diff?src=pr&el=tree#diff-c3JjL2VpbnN0ZWlucHkvcGxvdHRpbmcvZ2VvZGVzaWNzL3N0YXRpYy5weQ==) | `100% <0%> (+1.11%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?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/322?src=pr&el=footer). Last update [32d3c47...c1adefb](https://codecov.io/gh/einsteinpy/einsteinpy/pull/322?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ritzvik: Also can you edit `RicciScalar` to reflect the new changes?
pep8speaks: Hello @OVSofia! 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/symbolic/tensor.py`](https://github.com/einsteinpy/einsteinpy/blob/eb6d461366d61924c8014983f4e185bfab8af771/src/einsteinpy/symbolic/tensor.py):

> [Line 80:121](https://github.com/einsteinpy/einsteinpy/blob/eb6d461366d61924c8014983f4e185bfab8af771/src/einsteinpy/symbolic/tensor.py#L80): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (121 > 120 characters)




OVSofia: > Also can you edit `RicciScalar` to reflect the new changes?

Do you want to change code or just docstring?
ritzvik: > > Also can you edit `RicciScalar` to reflect the new changes?
> 
> Do you want to change code or just docstring?

the code, I was implying. Make it a derived class of `BaseRelativityTensor`
ritzvik: There was no need for changing tests in `RicciScalar`, we are not breaking any APIs.

Anyways, pull the new commits, squash and rebase 
OVSofia: > There was no need for changing tests in `RicciScalar`, we are not breaking any APIs.
> 
> Anyways, pull the new commits, squash and rebase


Yes, in fact I was just making the changes of your last commits
ritzvik: you might need to rebase one more time. Sorry xD
OVSofia: sorry, I had a big mess with git XDD
ritzvik: > you might need to rebase one more time. Sorry xD

.


> sorry, I had a big mess with git XDD

What happened? 🤣 
OVSofia: > > you might need to rebase one more time. Sorry xD
> 
> .
> 
> > sorry, I had a big mess with git XDD
> 
> What happened?


I had not pushed the last commit because I had seen your changes and started to give conflicts, 
which I have solved in an inefficient way xDD
OVSofia: @ritzvik I can not see why it's failing :/
ritzvik: Well the docs started failing out of the blue. I raised the issue in #324
diff --git a/src/einsteinpy/symbolic/constants.py b/src/einsteinpy/symbolic/constants.py
index 0ab4863..509082c 100644
--- a/src/einsteinpy/symbolic/constants.py
+++ b/src/einsteinpy/symbolic/constants.py
@@ -5,19 +5,24 @@ class SymbolicConstant(Symbol):
     """
     This class inherits from ~sympy.core.symbol.Symbol 
 
-    Parameters
-    ----------
-    name : str
-        Short, commonly accepted name of the constant. 
-        For example, 'c' for Speed of light.
-    descriptive_name : str
-        The extended name of the constant. 
-        For example, 'Speed of Light' for 'c'. 
-        Defaults to None.
-
     """
 
     def __new__(cls, name, descriptive_name=None, **assumptions):
+        """
+        Constructor and Initializer
+
+        Parameters
+        ----------
+        name : str
+            Short, commonly accepted name of the constant. 
+            For example, 'c' for Speed of light.
+        descriptive_name : str
+            The extended name of the constant. 
+            For example, 'Speed of Light' for 'c'. 
+            Defaults to None.
+
+        """
+
         instance = super(SymbolicConstant, cls).__new__(cls, name, **assumptions)
         instance._descriptive_name = descriptive_name
         return instance
diff --git a/src/einsteinpy/symbolic/ricci.py b/src/einsteinpy/symbolic/ricci.py
index 6c029c6..f9049b2 100644
--- a/src/einsteinpy/symbolic/ricci.py
+++ b/src/einsteinpy/symbolic/ricci.py
@@ -141,19 +141,20 @@ class RicciTensor(BaseRelativityTensor):
         return new_obj
 
 
-class RicciScalar:
+class RicciScalar(BaseRelativityTensor):
     """
+    Inherits from ~einsteinpy.symbolic.tensor.BaseRelativityTensor
     Class for defining Ricci Scalar
     """
 
-    def __init__(self, expression, syms, parent_metric=None):
+    def __init__(self, arr, syms, parent_metric=None):
         """
         Constructor and Initializer
 
         Parameters
         ----------
-        expression : ~sympy.core.expr.Expr
-            Any sympy expression
+        arr : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
+            Sympy Array, multi-dimensional list containing Sympy Expressions, or Sympy Expressions or int or float scalar
         syms : tuple or list
             Tuple of crucial symbols denoting time-axis, 1st, 2nd, and 3rd axis (t,x1,x2,x3)
         parent_metric : ~einsteinpy.symbolic.metric.MetricTensor or None
@@ -166,14 +167,11 @@ class RicciScalar:
             Raised when syms is not a list or tuple
 
         """
+        super(RicciScalar, self).__init__(
+            arr=arr, syms=syms, config="", parent_metric=parent_metric
+        )
         self._order = 0
-        self._parent_metric = parent_metric
-        self._expr = expression
-        if isinstance(syms, (list, tuple)):
-            self.syms = syms
-            self.dims = len(self.syms)
-        else:
-            raise TypeError("syms should be a list or tuple")
+        self._expr = self.arr[0]
 
     @property
     def expr(self):
@@ -182,13 +180,6 @@ class RicciScalar:
         """
         return self._expr
 
-    @property
-    def parent_metric(self):
-        """
-        Returns the Parent Metric, if available.
-        """
-        return self._parent_metric
-
     @classmethod
     def from_riccitensor(cls, riccitensor, parent_metric=None):
         """
diff --git a/src/einsteinpy/symbolic/tensor.py b/src/einsteinpy/symbolic/tensor.py
index 5bf381d..fbd55ff 100644
--- a/src/einsteinpy/symbolic/tensor.py
+++ b/src/einsteinpy/symbolic/tensor.py
@@ -1,6 +1,7 @@
 import numpy as np
 import sympy
 from sympy import simplify, tensorcontraction, tensorproduct
+from sympy.core.expr import Expr
 from sympy.core.function import AppliedUndef, UndefinedFunction
 
 
@@ -76,7 +77,7 @@ class Tensor:
         Parameters
         ----------
         arr : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
-            Sympy Array or multi-dimensional list containing Sympy Expressions
+            Sympy Array, multi-dimensional list containing Sympy Expressions, or Sympy Expressions or int or float scalar
         config : str
             Configuration of contravariant and covariant indices in tensor. 'u' for upper and 'l' for lower indices. Defaults to 'll'.
 
@@ -89,7 +90,7 @@ class Tensor:
 
         """
 
-        if isinstance(arr, (list, tuple, np.ndarray)):
+        if isinstance(arr, (list, tuple, np.ndarray, int, float, Expr)):
             self.arr = sympy.Array(arr)
         elif isinstance(arr, sympy.Array):
             self.arr = arr

Extend support of Tensor Class(symbolic) to support scalars
🐞 **Problem**
Scalars are also zero order tensors. The Tensor class currently supports 1st order tensors and above.

🎯 **Goal**

  - Make `Tensor` support scalars. This issue can also help in #287 .

📋  **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 🎉

diff --git a/src/einsteinpy/tests/test_symbolic/test_tensor.py b/src/einsteinpy/tests/test_symbolic/test_tensor.py
index 36eff8f..7d85b44 100644
--- a/src/einsteinpy/tests/test_symbolic/test_tensor.py
+++ b/src/einsteinpy/tests/test_symbolic/test_tensor.py
@@ -1,5 +1,7 @@
 import numpy as np
+import pytest
 from sympy import Array, Function, cos, simplify, sin, symbols
+from sympy.abc import y, z
 
 from einsteinpy.symbolic.tensor import BaseRelativityTensor, Tensor
 
@@ -72,15 +74,6 @@ def test_Tensor_repr():
     assert not "object at 0x" in machine_representation
 
 
-def test_TypeError1():
-    arr = 0
-    try:
-        obj = Tensor(arr)
-        assert False
-    except TypeError:
-        assert True
-
-
 def test_TypeError2():
     scht = schwarzschild_tensor().tensor()
     # pass non str object
@@ -147,3 +140,12 @@ def test_BaseRelativityTensor_automatic_calculation_of_free_variables():
             and (f in t2.functions)
             and (f in functions)
         )
+
+
+# tests fot Tensor Class to support scalars and sympy expression type scalars
+
+
+@pytest.mark.parametrize("scalar", [11.89, y * z + 5])
+def test_tensor_scalar(scalar):
+    scalar_tensor = Tensor(scalar)
+    assert scalar_tensor.tensor().rank() == 0

pip install -e .[dev]
parse_log_pytest
pytest
pytest
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
astropy==4.3.1
attrs @ file:///croot/attrs_1668696182826/work
Babel==2.14.0
backcall==0.2.0
beautifulsoup4==4.13.3
black==23.3.0
bleach==6.0.0
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
comm==0.1.4
coverage==7.2.7
cycler==0.11.0
debugpy==1.7.0
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.9
docutils==0.19
-e git+https://github.com/einsteinpy/einsteinpy.git@f2a9856b6be7fe81b21f302cbce0accd2b4383f6#egg=einsteinpy
entrypoints==0.4
execnet==2.0.2
fastjsonschema==2.21.1
filelock==3.12.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
fonttools==4.38.0
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
importlib-resources==5.12.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
ipykernel==6.16.2
ipython==7.34.0
ipywidgets==8.1.5
isort==5.11.5
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.17.3
jupyter-sphinx==0.4.0
jupyter_client==7.4.9
jupyter_core==4.12.0
jupyterlab-pygments==0.2.2
jupyterlab_widgets==3.0.13
kiwisolver==1.4.5
llvmlite==0.39.1
MarkupSafe==2.1.5
matplotlib==3.5.3
matplotlib-inline==0.1.6
mistune==3.0.2
mpmath==1.3.0
mypy-extensions==1.0.0
nbclient==0.7.4
nbconvert==7.6.0
nbformat==5.8.0
nbsphinx==0.9.7
nest-asyncio==1.6.0
numba==0.56.4
numpy==1.21.6
packaging==24.0
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.11.2
pexpect==4.9.0
pickleshare==0.7.5
Pillow==9.5.0
pkgutil_resolve_name==1.3.10
platformdirs==4.0.0
plotly==5.18.0
pluggy==1.2.0
prompt_toolkit==3.0.48
psutil==7.0.0
ptyprocess==0.7.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.10.0
pyerfa==2.0.0.3
Pygments==2.17.2
pyparsing==3.1.4
pyproject-api==1.5.3
pyrsistent==0.19.3
pytest==7.1.2
pytest-cov==2.5.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
pytz==2025.2
pyzmq==26.2.1
requests==2.31.0
scipy==1.7.3
six==1.17.0
snowballstemmer==2.2.0
soupsieve==2.4.1
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sympy==1.10.1
tenacity==8.2.3
tinycss2==1.2.1
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
tornado==6.2
tox==4.8.0
traitlets==5.9.0
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
virtualenv==20.26.6
wcwidth==0.2.13
webencodings==0.5.1
widgetsnbextension==4.0.13
zipp @ file:///croot/zipp_1672387121353/work

name: einsteinpy
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - astropy==4.3.1
      - babel==2.14.0
      - backcall==0.2.0
      - beautifulsoup4==4.13.3
      - black==23.3.0
      - bleach==6.0.0
      - cachetools==5.5.2
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - colorama==0.4.6
      - comm==0.1.4
      - coverage==7.2.7
      - cycler==0.11.0
      - debugpy==1.7.0
      - decorator==5.1.1
      - defusedxml==0.7.1
      - distlib==0.3.9
      - docutils==0.19
      - einsteinpy==0.3.dev0
      - entrypoints==0.4
      - execnet==2.0.2
      - fastjsonschema==2.21.1
      - filelock==3.12.2
      - fonttools==4.38.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==6.7.0
      - importlib-resources==5.12.0
      - ipykernel==6.16.2
      - ipython==7.34.0
      - ipywidgets==8.1.5
      - isort==5.11.5
      - jedi==0.19.2
      - jinja2==3.1.6
      - jsonschema==4.17.3
      - jupyter-client==7.4.9
      - jupyter-core==4.12.0
      - jupyter-sphinx==0.4.0
      - jupyterlab-pygments==0.2.2
      - jupyterlab-widgets==3.0.13
      - kiwisolver==1.4.5
      - llvmlite==0.39.1
      - markupsafe==2.1.5
      - matplotlib==3.5.3
      - matplotlib-inline==0.1.6
      - mistune==3.0.2
      - mpmath==1.3.0
      - mypy-extensions==1.0.0
      - nbclient==0.7.4
      - nbconvert==7.6.0
      - nbformat==5.8.0
      - nbsphinx==0.9.7
      - nest-asyncio==1.6.0
      - numba==0.56.4
      - numpy==1.21.6
      - packaging==24.0
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pathspec==0.11.2
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pillow==9.5.0
      - pkgutil-resolve-name==1.3.10
      - platformdirs==4.0.0
      - plotly==5.18.0
      - pluggy==1.2.0
      - prompt-toolkit==3.0.48
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pycodestyle==2.10.0
      - pyerfa==2.0.0.3
      - pygments==2.17.2
      - pyparsing==3.1.4
      - pyproject-api==1.5.3
      - pyrsistent==0.19.3
      - pytest-cov==2.5.1
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyzmq==26.2.1
      - requests==2.31.0
      - scipy==1.7.3
      - six==1.17.0
      - snowballstemmer==2.2.0
      - soupsieve==2.4.1
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - sympy==1.10.1
      - tenacity==8.2.3
      - tinycss2==1.2.1
      - tornado==6.2
      - tox==4.8.0
      - traitlets==5.9.0
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - virtualenv==20.26.6
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - widgetsnbextension==4.0.13
prefix: /opt/conda/envs/einsteinpy

src/einsteinpy/tests/test_symbolic/test_tensor.py::test_tensor_scalar[11.89] src/einsteinpy/tests/test_symbolic/test_tensor.py::test_tensor_scalar[scalar1]
src/einsteinpy/tests/test_symbolic/test_tensor.py::test_Tensor src/einsteinpy/tests/test_symbolic/test_tensor.py::test_Tensor_getitem src/einsteinpy/tests/test_symbolic/test_tensor.py::test_Tensor_str src/einsteinpy/tests/test_symbolic/test_tensor.py::test_Tensor_repr src/einsteinpy/tests/test_symbolic/test_tensor.py::test_TypeError2 src/einsteinpy/tests/test_symbolic/test_tensor.py::test_TypeError3 src/einsteinpy/tests/test_symbolic/test_tensor.py::test_subs_single src/einsteinpy/tests/test_symbolic/test_tensor.py::test_subs_multiple src/einsteinpy/tests/test_symbolic/test_tensor.py::test_check_properties src/einsteinpy/tests/test_symbolic/test_tensor.py::test_BaseRelativityTensor_automatic_calculation_of_free_variables
src/einsteinpy/symbolic/ricci.py src/einsteinpy/symbolic/constants.py src/einsteinpy/symbolic/tensor.py
src/einsteinpy/symbolic/ricci.py src/einsteinpy/symbolic/constants.py src/einsteinpy/symbolic/tensor.py