Python | Numpy np.assert_equal() method (original) (raw)

Last Updated : 23 Jan, 2020

With the help of **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.

Python3 1=1 `

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)

`

Output :

None

Example #2 :

Python3 1=1 `

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)

`

Output :

AssertionError: Items are not equal: item=0 ACTUAL: 1 DESIRED: 5