Numpy判斷數(shù)組是否相等一般是判斷兩個(gè)數(shù)組是否完全相等
(array1 == array2) 返回兩個(gè)矩陣中對(duì)應(yīng)元素是否相等的邏輯值
(array1 == array2).all()當(dāng)兩個(gè)矩陣所有對(duì)應(yīng)元素相等,返回一個(gè)邏輯值True
(array1 == array2).any()當(dāng)兩個(gè)矩陣所有任何一個(gè)對(duì)應(yīng)元素相等,返回一個(gè)邏輯值True
>>> a = np.array([1,2,3])
>>> b = np.array([1,2,3])
>>> c = np.array([1,2,4])
>>> a == b
array([ True, True, True])
>>> a == c
array([ True, True, False])
>>> (a == b).all()
True
>>> (a == c).all()
False
>>> (a == b).any()
True
>>> (a == c).any()
True
>>>