SHARE
TWEET

Untitled

a guest Oct 14th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def find_rows(a, b):
  2.     dt = np.dtype((np.void, a.dtype.itemsize * a.shape[1]))
  3.  
  4.     a_view = np.ascontiguousarray(a).view(dt).ravel()
  5.     b_view = np.ascontiguousarray(b).view(dt).ravel()
  6.  
  7.     sort_b = np.argsort(b_view)
  8.     where_in_b = np.searchsorted(b_view, a_view,
  9.                                  sorter=sort_b)
  10.     where_in_b = np.take(sort_b, where_in_b)
  11.     which_in_a = np.take(b_view, where_in_b) == a_view
  12.     where_in_b = where_in_b[which_in_a]
  13.     which_in_a = np.nonzero(which_in_a)[0]
  14.     return np.column_stack((which_in_a, where_in_b))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top