Comparisons

Comparisons can be elementwise or arraywise.

Elementwise comparisons

a = np.arange(5)
b = np.array([5, 1, 9, 6, 4])
 
a < b
# array([ True, False,  True,  True, False])
 
a == b
# array([False,  True, False, False,  True])

Arraywise comparisons

Comparisons on the arrays instead of individual elements. Methods such as np.array_equal, np.array_equiv etc are used for arraywise comparisons.

np.array_equal(a, b)
# False

np.array_equal checks if two arrays have same shape and elements.