<p dir="auto">I don't see any reason why the first input <code class="notranslate">ar1</code> needs to be one dimensional. If not for this limitation, I think it would perfectly answer my question here: <a href="http://stackoverflow.com/q/41318942/125507" rel="nofollow">http://stackoverflow.com/q/41318942/125507</a></p>
<p dir="auto">in1d takes two arrays, <code class="notranslate">ar1</code> and <code class="notranslate">ar2</code>, and returns a 1d array with the same number of elements as <code class="notranslate">ar1</code>. The logical extension would be a function that does the same thing but returns a (possibly multi-dimensional) array of the same shape as <code class="notranslate">ar1</code>. Effectively, it would be equivalent to this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def in(ar1, ar2, **kwargs):
  return np.in1d(ar1, ar2, **kwargs).reshape(ar1.shape)"><pre class="notranslate"><code class="notranslate">def in(ar1, ar2, **kwargs):
  return np.in1d(ar1, ar2, **kwargs).reshape(ar1.shape)
</code></pre></div>
<p dir="auto">although it might be implemented differently.</p>