I want to get the set difference of arrays of tuples. For instance, for
import numpy as np
a = np.empty((2,), dtype=object)
a[0] = (0, 1)
a[1] = (2, 3)
b = np.empty((1,), dtype=object)
b[0] = (2, 3)
I would like to have a function, say set_diff
, such that set_diff(a, b) = array([(0, 1)], dtype=object)
. The function np.setdiff1d
doesn't work, np.setdiff1d(a, b)
yields array([(0, 1), (2, 3)], dtype=object)
.
Is there a function that does the job or a way to make np.setdiff1d
have the desired behavior ?