Let's say I've created an integer 2d array:
import numpy as np
ar1 = np.random.randint(10, size=(4,2))
v1 = ar1[0]
v2 = [4,4]
ar1 = np.array([[5, 7],
[7, 5],
[9, 2],
[0, 1]])
I want to check if v1 and v2 are elements of ar1. By 'elements' I mean 'rows':
v1 in ar1
v2 in ar1
And I get True
in both cases. What am I doing wrong? Is there a better way to check if the vector matches a row of the array? Looping through rows (i.e. for rows in ar1:
) is not an option.
EDIT: another way is to sum matching values in every row and check if the sum is 2, but it's lame and unpythonic