I think the original post was due to a misunderstanding in combining logical operation (such as ==) and methods np.any() and np.all() when comparing 2 tables. Following the answer from @user2653663, I thought it is worth to complete it by the following example:
import numpy as np
a = np.asarray([1,2,3])
b = np.asarray([1,0,1])
print((a == b).any())
print((a == b).all())
True
False
The first print will return True as the compare operation "cell by cell" found at least 1 equal cell in both tables; which is in our case a[0] == b[0]. As the second returned False because not all cells are equals. You can easily visualize why by doing:
print(a == b)
[ True False False]
False
. Since your examples don't have any 0s, bothall
andany
returnTrue
. – Guillemota
with anything inb
. The two expressions,a.any()
andb.all()
are evaluated on their own (and as explained in the other comments, both evaluate toTrue
), so what you end up checking isTrue == True
, which is alsoTrue
. – Auricle