get_positions_where_values_in#
- skrough.utils.get_positions_where_values_in(values: ndarray, reference: ndarray) List[int][source]#
Compute positions for which values are in the
referencecollection.Compute positions for which
valueselements are in thereferencecollection. It is equivalent tonp.isin(values, reference).nonzero()[0]but should be faster for largerreferencecollections.- Parameters:
values – An input collection of values for which the check if its elements are in the
referencecollection.reference – A collection of reference values for which the
valueselements are checked against.
- Returns:
A collection of indices for which the elements of
valueson the given positions are in thereferencecollection.
Examples
>>> get_positions_where_values_in(np.asarray([2, 7, 1, 8]), np.asarray([1, 8])) [2, 3] >>> get_positions_where_values_in(np.asarray([1, 2, 1, 1]), np.asarray([1, 8])) [0, 1, 3]