Check if numpy array is in list of numpy arrays

There is a much simpler way without the need to loop using np.all(). It only works when all the arrays within the list of arrays have the same shape:

list_np_arrays = np.array([[1., 1.], [1., 2.]])
array_to_check = np.array([1., 2.])

is_in_list = np.any(np.all(array_to_check == list_np_arrays, axis=1))

The variable is_in_list indicates if there is any array within he list of numpy arrays which is equal to the array to check.

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş