Combine Numpy “where” statements
问题 I am trying to speed up a code that is using Numpy's where() function. There are two calls to where() , which return an array of indices for where the statement is evaluated as True , which are then compared for overlap with numpy's intersect1d() function, of which the length of the intersection is returned. import numpy as np def find_match(x,y,z): A = np.where(x == z) B = np.where(y == z) #A = True #B = True return len(np.intersect1d(A,B)) N = np.power(10, 8) M = 10 X = np.random.randint(M,