pyyeti.locate.find_subseq

pyyeti.locate.find_subseq(seq, subseq)[source]

Returns indices of where subseq occurs in seq. Both are 1d numpy arrays.

Parameters:
  • seq (array_like) – Array to search in. It is flattened before searching.

  • subseq (array_like) – Array to search for. It is flattened before searching.

Returns:

pv (1d ndarray) –

Vector of indices:

  • length will be equal to the number of occurrences of subseq

  • the indices are to the start of each subseq in seq

Will be empty if subseq is not found in seq.

Examples

>>> from pyyeti import locate
>>> a = [1, 2, 3, 4, 5, 6, 2, 3]
>>> sub = [2, 3]
>>> locate.find_subseq(a, sub)
array([1, 6]...)
>>> locate.find_subseq(a, [6, 5])
array([], dtype=int64)