https://github.com/hansalemaos/stridessequencefinder
finds sequences [3, 4, 5] in NumPy arrays [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - result: [2 7]
https://github.com/hansalemaos/stridessequencefinder
arrays find numexpr numpy sequence
Last synced: about 1 month ago
JSON representation
finds sequences [3, 4, 5] in NumPy arrays [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - result: [2 7]
- Host: GitHub
- URL: https://github.com/hansalemaos/stridessequencefinder
- Owner: hansalemaos
- License: mit
- Created: 2023-09-11T20:10:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-11T20:10:34.000Z (over 2 years ago)
- Last Synced: 2025-12-17T03:42:16.596Z (5 months ago)
- Topics: arrays, find, numexpr, numpy, sequence
- Language: Python
- Homepage: https://pypi.org/project/stridessequencefinder/
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# 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
```python
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]
```