Skip to main content

finds sequences [3, 4, 5] in NumPy arrays [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - result: [2 7]

Project description

finds sequences [3, 4, 5] in NumPy arrays [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - result: [2 7]

Tested against Windows 10 / Python 3.10 / Anaconda

pip install stridessequencefinder

Find occurrences of a sequence in a 1-dimensional NumPy array using a rolling window approach.

Parameters:
sequence (numpy.ndarray): The sequence to search for.
array (numpy.ndarray): The input array to search within.
numexpr_enabled (bool, optional): Whether to use NumExpr for efficient computation (default is True).

Returns:
numpy.ndarray: An array of indices where the sequence is found in the input array.

Example:
>>> arr = np.array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5])
>>> seq = np.array([3, 4, 5])
>>> indices = find_sequence_in_array(seq, arr)
>>> print(indices)
[2 7]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stridessequencefinder-0.10.tar.gz (20.3 kB view hashes)

Uploaded Source

Built Distribution

stridessequencefinder-0.10-py3-none-any.whl (21.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page