I have two arrays arr1 and arr2 with sizes (90000,1) and (120000,1). I'd like to find out if any element of axis=0 of arr1 is present on arr2. Then write their positions on to a list and later remove them. This will ensure that none of the elements on either lists could be found on the other. For now, I'm using for loops:
list_conflict=[]
for i in range (len(arr1)):
for j in range (len(arr2)):
if (arr1[i]==arr2[j]):
list_conflict.append([i,j])
fault_index_pos = np.unique([x[0] for x in list_conflict])
fault_index_neg = np.unique([x[1] for x in list_conflict])
X_neg = np.delete(X_neg,fault_index_neg,axis=0)
X_pos = np.delete(X_pos,fault_index_pos,axis=0)
It takes an element of arr1 on outer loop and compares it with every element of arr2 exhaustively. If finds a match, appends indices list_conflict with first element being arr1 position and second arr2. Then fault_index_pos and fault_index_neg are squeezed into unique elements, since an element of arr1 could be on multiple places of arr2 and list will have recurrent positions. Finally, matching elements are removed with np.delete by taking fault_index lists as index to be deleted.
I'm looking for a faster approach for conflict comparison call it multiprocessing, vectorization or anything else. You could say it won't take much time but actually arrays are in (x,8,10) dimensions but I shortened them for sake of clarity.