w3resource

NumPy Logic functions: array_equiv() function

numpy.array_equiv() function

The array_equiv() is used to returns True if input arrays are shape consistent and all elements equal.

Shape consistent means they are either the same shape, or one input array can be broadcasted to create the same shape as the other one.

Syntax:

numpy.array_equiv(a1, a2)

Version: 1.15.0

Parameter:

Name Description Required /
Optional
a1, a2 Input arrays.
array_like
Required

Returns:
out : bool - True if equivalent, False otherwise.

NumPy.array_equiv() method Example-1:

>>> import numpy as np
>>> np.array_equiv([2, 4], [2, 4])

Output:

True

NumPy.array_equiv() method Example-2:

>>> import numpy as np
>>> np.array_equiv([2, 4], [4, 2])

Output:

False

Showing the shape equivalence:

NumPy.array_equiv() method Example-3:

>>> import numpy as np
>>> np.array_equiv([2, 5], [[2, 5], [2, 5]])

Output:

True

NumPy.array_equiv() method Example-4:

>>> import numpy as np
>>> np.array_equiv([2, 5], [[2, 5, 2, 5], [5, 2, 5, 2]])

Output:

False

NumPy.array_equiv() method Example-5:

>>> import numpy as np
>>> np.array_equiv([2, 4], [[2, 4], [5, 2]])

Output:

False

Python - NumPy Code Editor:

Previous: array_equal() function
Next: greater() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/numpy/logic-functions/array_equiv.php