title: Cartesian (cross) products and np.unique()
body: <p>Depending on your few on my approach this is either a question about using <code>np.unique()</code> on <code>awkward1</code> arrays or a call for a better approach:</p>
  <p>Let <code>a</code> and <code>b</code> be two <code>awkward1</code> arrays of the same outer length (number of events) but different inner lengths. For example:</p>
  <p><code>a = [[1, 2], [3]   , [] , [4, 5, 6]]</code></p>
  <p><code>b = [[7]   , [3, 5], [6], [8, 9]]</code></p>
  <p>Let <code>f: (x, y) -&gt; z</code> be a function that acts on two numbers <code>x</code> and <code>y</code> and results in the number <code>z</code>. For example:</p>
  <p><code>f(x, y):= y - x</code></p>
  <p>The idea is to compare every element in <code>a</code> with every element in <code>b</code> via <code>f</code> for each event and filter out the matches of <code>a</code> and <code>b</code> pairs that survive some cut applied to <code>f</code>. For example:</p>
  <p><code>f(x, y) &lt; 4</code></p>
  <p>My approach for this is:</p>
  <pre><code>a = ak.from_iter(a)
  b = ak.from_iter(b)
  
  c = ak.cartesian({'x':a, 'y':b})
  #c= [[{'x': 1, 'y': 7}, {'x': 2, 'y': 7}], [{'x': 3, 'y': 3}, {'x': 3, 'y': 5}], [], [{'x': 4, 'y': 8}, {'x': 4, 'y': 9}, {'x': 5, 'y': 8}, {'x': 5, 'y': 9}, {'x': 6, 'y': 8}, {'x': 6, 'y': 9}]]
  
  i = ak.argcartesian({'x':a, 'y':b})
  #i= [[{'x': 0, 'y': 0}, {'x': 1, 'y': 0}], [{'x': 0, 'y': 0}, {'x': 0, 'y': 1}], [], [{'x': 0, 'y': 0}, {'x': 0, 'y': 1}, {'x': 1, 'y': 0}, {'x': 1, 'y': 1}, {'x': 2, 'y': 0}, {'x': 2, 'y': 1}]]
  
  diff = c['y'] - c['x']
  #diff= [[6, 5], [0, 2], [], [4, 5, 3, 4, 2, 3]]
  
  cut = diff &lt; 4
  #cut= [[False, False], [True, True], [], [False, False, True, False, True, True]]
  
  new = c[cut]
  #new= [[], [{'x': 3, 'y': 3}, {'x': 3, 'y': 5}], [], [{'x': 5, 'y': 8}, {'x': 6, 'y': 8}, {'x': 6, 'y': 9}]]
  
  new_i = i[cut]
  #new_i= [[], [{'x': 0, 'y': 0}, {'x': 0, 'y': 1}], [], [{'x': 1, 'y': 0}, {'x': 2, 'y': 0}, {'x': 2, 'y': 1}]]
  </code></pre>
  <p>It is possible that pairs with the same element from <code>a</code> but different elements from <code>b</code> survive the cut. (e.g. <code>{'x': 3, 'y': 3}</code> and <code>{'x': 3, 'y': 5}</code>)</p>
  <p>My goal is to group those pairs with the same element from <code>a</code> together and therefore reshape the <code>new</code> array into:</p>
  <p><code>new = [[], [{'x': 3, 'y': [3, 5]}], [], [{'x': 5, 'y': 8}, {'x': 6, 'y': [8, 9]}]]</code></p>
  <p>My only idea how to achieve this is to create a list of the indexes from <code>a</code> that are still present after the cut by using <code>new_i</code>:</p>
  <pre><code>i = new_i['x']
  #i= [[], [0, 0], [], [1, 2, 2]]
  </code></pre>
  <p>However, I need a unique version of this list to make every index appear only once. This could be achieved with <code>np.unique()</code> in NumPy. But doesn't work in <code>awkward1</code>:</p>
  <pre><code>np.unique(i)
  
  &lt;__array_function__ internals&gt; in unique(*args, **kwargs)
  
  TypeError: no implementation found for 'numpy.unique' on types that implement __array_function__: [&lt;class 'awkward1.highlevel.Array'&gt;]
  </code></pre>
  <p>My question:</p>
  <p>Is their a <code>np.unique()</code> equivalent in <code>awkward1</code> and/or would you recommend a different approach to my problem?</p>