parameters: (ar1, ar2, assume_unique=False, invert=False)
docstring: Test whether each element of an array is also present in a second
      array.
  
      The output is always a masked array. See `numpy.in1d` for more details.
  
      We recommend using :func:`isin` instead of `in1d` for new code.
  
      See Also
      --------
      isin       : Version of this function that preserves the shape of ar1.
      numpy.in1d : Equivalent function for ndarrays.
  
      Notes
      -----
      .. versionadded:: 1.4.0
docstring_summary: Test whether each element of an array is also present in a second
      array.
docstring_tokens: Test whether each element of an array is also present in a second array .
function: def in1d(ar1, ar2, assume_unique=False, invert=False):
      """
      Test whether each element of an array is also present in a second
      array.
  
      The output is always a masked array. See `numpy.in1d` for more details.
  
      We recommend using :func:`isin` instead of `in1d` for new code.
  
      See Also
      --------
      isin       : Version of this function that preserves the shape of ar1.
      numpy.in1d : Equivalent function for ndarrays.
  
      Notes
      -----
      .. versionadded:: 1.4.0
  
      """
      if not assume_unique:
          ar1, rev_idx = unique(ar1, return_inverse=True)
          ar2 = unique(ar2)
  
      ar = ma.concatenate((ar1, ar2))
      # We need this to be a stable sort, so always use 'mergesort'
      # here. The values from the first array should always come before
      # the values from the second array.
      order = ar.argsort(kind='mergesort')
      sar = ar[order]
      if invert:
          bool_ar = (sar[1:] != sar[:-1])
      else:
          bool_ar = (sar[1:] == sar[:-1])
      flag = ma.concatenate((bool_ar, [invert]))
      indx = order.argsort(kind='mergesort')[:len(ar1)]
  
      if assume_unique:
          return flag[indx]
      else:
          return flag[indx][rev_idx]
function_tokens: def in1d ( ar1 , ar2 , assume_unique = False , invert = False ) : if not assume_unique : ar1 , rev_idx = unique ( ar1 , return_inverse = True ) ar2 = unique ( ar2 ) ar = ma . concatenate ( ( ar1 , ar2 ) ) # We need this to be a stable sort, so always use 'mergesort' # here. The values from the first array should always come before # the values from the second array. order = ar . argsort ( kind = 'mergesort' ) sar = ar [ order ] if invert : bool_ar = ( sar [ 1 : ] != sar [ : - 1 ] ) else : bool_ar = ( sar [ 1 : ] == sar [ : - 1 ] ) flag = ma . concatenate ( ( bool_ar , [ invert ] ) ) indx = order . argsort ( kind = 'mergesort' ) [ : len ( ar1 ) ] if assume_unique : return flag [ indx ] else : return flag [ indx ] [ rev_idx ]