Python | Numpy np.assert_equal() method
Last Updated :
23 Jan, 2020
Improve
With the help of
Python3 1=1
Output :
Python3 1=1
Output :
np.assert_equal()
method, we can get the assertion error when two objects are not equal by using np.assert_equal()
method.
Syntax : np.assert_equal(actual, desired)
Return : Return assertion error if two object are unequal.
Example #1 :
In this example we can see that by using np.assert_equal()
method, we are able to get the assertion error when two objects are not equal by using this method.
# import numpy and assert_equal
import numpy as np
import numpy.testing as npt
# using np.assert_equal() method
gfg = npt.assert_equal([1, 2], [1, 2])
print(gfg)
NoneExample #2 :
# import numpy and assert_equal
import numpy as np
import numpy.testing as npt
# using np.assert_equal() method
gfg = npt.assert_equal([1, 2], [5, 2])
print(gfg)
AssertionError: Items are not equal: item=0 ACTUAL: 1 DESIRED: 5