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
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics