question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assertion Error while testing

See original GitHub issue

🐞 Problem I got an AssertionError and a warning when running tests as given in the README.

I ran the following command.

pythonw -c "import einsteinpy.testing; einsteinpy.testing.test()"

🖥 Please paste the output of following commands

  • conda info -a

     active environment : epy
    active env location : /Users/rishi/miniconda3/envs/epy
            shell level : 1
       user config file : /Users/rishi/.condarc
 populated config files :
          conda version : 4.6.11
    conda-build version : not installed
         python version : 3.7.2.final.0
       base environment : /Users/rishi/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/osx-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/rishi/miniconda3/pkgs
                          /Users/rishi/.conda/pkgs
       envs directories : /Users/rishi/miniconda3/envs
                          /Users/rishi/.conda/envs
               platform : osx-64
             user-agent : conda/4.6.11 requests/2.21.0 CPython/3.7.2 Darwin/18.2.0 OSX/10.14.3
                UID:GID : 501:20
             netrc file : /Users/rishi/.netrc
           offline mode : False

WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
base                     /Users/rishi/miniconda3
epy                   *  /Users/rishi/miniconda3/envs/epy
sat                      /Users/rishi/miniconda3/envs/sat
tensorflow_env           /Users/rishi/miniconda3/envs/tensorflow_env
web                      /Users/rishi/miniconda3/envs/web

sys.version: 3.7.2 (default, Dec 29 2018, 00:00:04)
...
sys.prefix: /Users/rishi/miniconda3
sys.executable: /Users/rishi/miniconda3/bin/python
conda location: /Users/rishi/miniconda3/lib/python3.7/site-packages/conda
conda-build: None
conda-env: /Users/rishi/miniconda3/bin/conda-env
user site dirs:

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: epy
CONDA_EXE: /Users/rishi/miniconda3/bin/conda
CONDA_PREFIX: /Users/rishi/miniconda3/envs/epy
CONDA_PROMPT_MODIFIER: (epy)
CONDA_ROOT: /Users/rishi/miniconda3
CONDA_SHLVL: 1
FPATH: /Users/rishi/.zplug/autoload:/Users/rishi/.zplug/misc/completions:/Users/rishi/.zplug/base/sources:/Users/rishi/.zplug/base/utils:/Users/rishi/.zplug/base/job:/Users/rishi/.zplug/base/log:/Users/rishi/.zplug/base/io:/Users/rishi/.zplug/base/core:/Users/rishi/.zplug/base/base:/Users/rishi/.zplug/autoload/commands:/Users/rishi/.zplug/autoload/options:/Users/rishi/.zplug/autoload/tags:/usr/local/share/zsh/site-functions:/usr/share/zsh/site-functions:/usr/share/zsh/5.3/functions:/Users/rishi/.zplug/repos/zsh-users/zsh-completions/src
GEM_PATH: /Users/rishi/.rvm/gems/ruby-2.5.1:/Users/rishi/.rvm/gems/ruby-2.5.1@global
MANPATH: /Users/rishi/.nvm/versions/node/v10.14.0/share/man:/Users/rishi/miniconda3/share/man:/usr/share/man:/usr/local/share/man:/opt/X11/share/man:/Users/rishi/.fzf/man:/Library/Developer/CommandLineTools/usr/share/man
NVM_PATH: /Users/rishi/.nvm/versions/node/v10.14.0/lib/node
PATH: /Users/rishi/miniconda3/envs/epy/bin:/Users/rishi/.rvm/gems/ruby-2.5.1/bin:/Users/rishi/.rvm/gems/ruby-2.5.1@global/bin:/Users/rishi/.rvm/rubies/ruby-2.5.1/bin:/usr/local/sbin:/Users/rishi/.nvm/versions/node/v10.14.0/bin:/Users/rishi/miniconda3/condabin:/Users/rishi/.zplug/bin:/bin:/Users/rishi/miniconda3/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/bin:/Users/rishi/.fzf/bin:/Users/rishi/.rvm/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
_ZPLUG_AWKPATH: /Users/rishi/.zplug/misc/contrib
ftp_proxy: <set>
http_proxy: <set>
https_proxy: <set>
rvm_bin_path: /Users/rishi/.rvm/bin
rvm_path: /Users/rishi/.rvm
rvm_proxy: <set>
  • conda list (only if you have conda)
# Name                    Version                   Build  Channel
appnope                   0.1.0                    py37_0
astropy                   3.1.2                    pypi_0    pypi
atomicwrites              1.3.0                    py37_1
attrs                     19.1.0                   py37_1
backcall                  0.1.0                    py37_0
blas                      1.0                         mkl
bleach                    3.1.0                    py37_0
ca-certificates           2019.1.23                     0
certifi                   2019.3.9                 py37_0
chardet                   3.0.4                    pypi_0    pypi
cycler                    0.10.0                   pypi_0    pypi
dbus                      1.13.6               h90a0687_0
decorator                 4.4.0                    py37_1
defusedxml                0.5.0                    py37_1
einsteinpy                0.2.dev0                  dev_0    <develop>
entrypoints               0.3                      py37_0
expat                     2.2.6                h0a44026_0
gettext                   0.19.8.1             h15daf44_3
glib                      2.56.2               hd9629dc_0
icu                       58.2                 h4b95b61_1
idna                      2.8                      pypi_0    pypi
intel-openmp              2019.3                      199
ipykernel                 5.1.0            py37h39e3cac_0
ipython                   7.4.0            py37h39e3cac_0
ipython_genutils          0.2.0                    py37_0
ipywidgets                7.4.2                    py37_0
jedi                      0.13.3                   py37_0
jinja2                    2.10                     py37_0
jpeg                      9b                   he5867d9_2
jsonschema                3.0.1                    py37_0
jupyter                   1.0.0                    py37_7
jupyter_client            5.2.4                    py37_0
jupyter_console           6.0.0                    py37_0
jupyter_core              4.4.0                    py37_0
kiwisolver                1.0.1                    pypi_0    pypi
libcxx                    4.0.1                hcfea43d_1
libcxxabi                 4.0.1                hcfea43d_1
libedit                   3.1.20181209         hb402a30_0
libffi                    3.2.1                h475c297_4
libgfortran               3.0.1                h93005f0_2
libiconv                  1.15                 hdd342a3_7
libpng                    1.6.36               ha441bb4_0
libsodium                 1.0.16               h3efe00b_0
markupsafe                1.1.1            py37h1de35cc_0
matplotlib                3.0.3                    pypi_0    pypi
mistune                   0.8.4            py37h1de35cc_0
mkl                       2019.3                      199
mkl_fft                   1.0.10           py37h5e564d8_0
mkl_random                1.0.2            py37h27c97d8_0
more-itertools            6.0.0                    py37_0
mpmath                    1.1.0                    pypi_0    pypi
nbconvert                 5.4.1                    py37_3
nbformat                  4.4.0                    py37_0
ncurses                   6.1                  h0a44026_1
notebook                  5.7.8                    py37_0
numpy                     1.16.2           py37hacdab7b_0
numpy-base                1.16.2           py37h6575580_0
openssl                   1.1.1b               h1de35cc_1
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py37_1
parso                     0.3.4                    py37_0
pcre                      8.43                 h0a44026_0
pexpect                   4.6.0                    py37_0
pickleshare               0.7.5                    py37_0
pip                       19.0.3                   py37_0
plotly                    3.7.1                    pypi_0    pypi
pluggy                    0.9.0                    py37_0
prometheus_client         0.6.0                    py37_0
prompt_toolkit            2.0.9                    py37_0
ptyprocess                0.6.0                    py37_0
py                        1.8.0                    py37_0
pygments                  2.3.1                    py37_0
pyparsing                 2.3.1                    pypi_0    pypi
pyqt                      5.9.2            py37h655552a_2
pyrsistent                0.14.11          py37h1de35cc_0
pytest                    4.3.1                    py37_0
python                    3.7.3                h359304d_0
python-dateutil           2.8.0                    py37_0
pytz                      2018.9                   pypi_0    pypi
pyzmq                     18.0.0           py37h0a44026_0
qt                        5.9.7                h468cd18_1
qtconsole                 4.4.3                    py37_0
readline                  7.0                  h1de35cc_5
requests                  2.21.0                   pypi_0    pypi
retrying                  1.3.3                    pypi_0    pypi
scipy                     1.2.1                    pypi_0    pypi
send2trash                1.5.0                    py37_0
setuptools                40.8.0                   py37_0
sip                       4.19.8           py37h0a44026_0
six                       1.12.0                   py37_0
sqlite                    3.27.2               ha441bb4_0
sympy                     1.3                      pypi_0    pypi
terminado                 0.8.1                    py37_1
testpath                  0.4.2                    py37_0
tk                        8.6.8                ha441bb4_0
tornado                   6.0.2            py37h1de35cc_0
traitlets                 4.3.2                    py37_0
urllib3                   1.24.1                   pypi_0    pypi
wcwidth                   0.1.7                    py37_0
webencodings              0.5.1                    py37_1
wheel                     0.33.1                   py37_0
widgetsnbextension        3.4.2                    py37_0
xz                        5.2.4                h1de35cc_4
zeromq                    4.3.1                h0a44026_3
zlib                      1.2.11               h1de35cc_3
  • pip freeze
appnope==0.1.0
astropy==3.1.2
atomicwrites==1.3.0
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
certifi==2019.3.9
chardet==3.0.4
cycler==0.10.0
decorator==4.4.0
defusedxml==0.5.0
-e git+https://github.com/rishi-s8/einsteinpy.git@56bef0dafa05605d3bc31986384add443e3a37c6#egg=einsteinpy
entrypoints==0.3
idna==2.8
ipykernel==5.1.0
ipython==7.4.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.0.1
MarkupSafe==1.1.1
matplotlib==3.0.3
mistune==0.8.4
mkl-fft==1.0.10
mkl-random==1.0.2
more-itertools==6.0.0
mpmath==1.1.0
nbconvert==5.4.1
nbformat==4.4.0
notebook==5.7.8
numpy==1.16.2
pandocfilters==1.4.2
parso==0.3.4
pexpect==4.6.0
pickleshare==0.7.5
plotly==3.7.1
pluggy==0.9.0
prometheus-client==0.6.0
prompt-toolkit==2.0.9
ptyprocess==0.6.0
py==1.8.0
Pygments==2.3.1
pyparsing==2.3.1
pyrsistent==0.14.11
pytest==4.3.1
python-dateutil==2.8.0
pytz==2018.9
pyzmq==18.0.0
qtconsole==4.4.3
requests==2.21.0
retrying==1.3.3
scipy==1.2.1
Send2Trash==1.5.0
six==1.12.0
sympy==1.3
terminado==0.8.1
testpath==0.4.2
tornado==6.0.2
traitlets==4.3.2
urllib3==1.24.1
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2
  • python -c "import einsteinpy.testing; einsteinpy.testing.test()"
==================================================================== test session starts =====================================================================
platform darwin -- Python 3.7.0, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: /Users/rishi/Documents/GitHub/einsteinpy, inifile: setup.cfg
collected 72 items

src/einsteinpy/tests/test_constant.py ...                                                                                                              [  4%]
src/einsteinpy/tests/test_integrators/test_runge_kutta.py .                                                                                            [  5%]
src/einsteinpy/tests/test_metric/test_kerr.py ......                                                                                                   [ 13%]
src/einsteinpy/tests/test_metric/test_kerrnewman.py ....                                                                                               [ 19%]
src/einsteinpy/tests/test_metric/test_schwarzschild.py .........                                                                                       [ 31%]
src/einsteinpy/tests/test_plotting/test_scattergeodesicplotter.py ....                                                                                 [ 37%]
src/einsteinpy/tests/test_plotting/test_staticgeodesicplotter.py ...                                                                                   [ 41%]
src/einsteinpy/tests/test_utils/test_bl_coord_transforms.py ...............                                                                            [ 62%]
src/einsteinpy/tests/test_utils/test_christoffel.py .....                                                                                              [ 69%]
src/einsteinpy/tests/test_utils/test_coord_transforms.py .....                                                                                         [ 76%]
src/einsteinpy/tests/test_utils/test_kerr_utils.py ........                                                                                            [ 87%]
src/einsteinpy/tests/test_utils/test_kerrnewman_utils.py .......F                                                                                      [ 98%]
src/einsteinpy/tests/test_utils/test_schwarzschild_utils.py .                                                                                          [100%]

========================================================================== FAILURES ==========================================================================
_________________________________ test_maxwell_tensor_contravariant_for_natural_units[1e+22-5.5-1.2566370614359172-45.0-0.7] _________________________________

M = 1e+22, r = 5.5, theta = 1.2566370614359172, Q = 45.0, a = 0.7

    @pytest.mark.parametrize("M, r, theta, Q, a", [(1e22, 5.5, 2 * np.pi / 5, 45.0, 0.7)])
    def test_maxwell_tensor_contravariant_for_natural_units(M, r, theta, Q, a):
        # Theoritical background required to write extensive test. Right now only skew-symettric property is being checked.
        m = kerrnewman_utils.maxwell_tensor_contravariant(1.0, 1.0, 1.0, r, theta, a, Q, M)
        for t in range(16):
            i = int(t / 4) % 4
            j = t % 4
>           assert_allclose(0, m[i, j] + m[j, i], rtol=0.0, atol=1e-10)
E           AssertionError:
E           Not equal to tolerance rtol=0, atol=1e-10
E
E           (mismatch 100.0%)
E            x: array(0)
E            y: array(-1.)

src/einsteinpy/tests/test_utils/test_kerrnewman_utils.py:140: AssertionError
====================================================================== warnings summary ======================================================================
src/einsteinpy/tests/test_plotting/test_scattergeodesicplotter.py::test_plot_attractor_is_called_only_once
  /Users/rishi/miniconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py:4204: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    (isinstance(c, collections.Iterable) and

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================================================== 1 failed, 71 passed, 1 warnings in 21.43 seconds ======================================================

🎯 Goal

Fix the AssertionError

💡 Possible solutions

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

Expected behavior The tests should have succeed as given in the screenshot in the README.

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS Mojave

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
pmk21commented, Apr 8, 2019

Getting the exact same error on Linux too.

1reaction
shreyasbapatcommented, Apr 7, 2019

@rishi-s8 Meanwhile, your installation is correct. I will try to figure out what this is!

Read more comments on GitHub >

github_iconTop Results From Across the Web

assertion error in junit test in java - Stack Overflow
you are trying to assert two different java object which are logically same, One which you created and other is returned ...
Read more >
How to View Multiple JUnit Assertion Errors in One Test ...
When JUnit Assertion errors (test failures) occur, your test will stop executing and will not perform any remaining Assertions.
Read more >
Python | Assertion Error - GeeksforGeeks
Assertion is a programming concept used while writing a code where the user declares a condition to be true using assert statement prior...
Read more >
What is java.lang.AssertionError in junit java
AssertionError occurs with example in java junit. ... AssertionError in java >. assertTrue(boolean) - Method tests whether a value returned is true in...
Read more >
Assertion Error when testing ...
My code below is returning an AssertionError: assert 0 == 1. Brownie v1.16.4 - Python development framework for Ethereum ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found