I used scipy.spatial.KDTree.query_pairs() which returned a python set of tuples. Let's say, this is the output:
set1 = {(2, 3), (4, 5), (1, 6), (6, 7), (3, 8), (6, 8)}
Next, I want to erase all the tuples in the set which do not fulfill the condition
arr = [6, 7]
tuple[0] in arr or tuple[1] in arr
What would be the most elegant/fast/pythonic way? Should I maybe convert to a numpy array?