Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eric-wieser/numpy_ringbuffer
Ring-buffer implementation that thinly wraps a numpy array
https://github.com/eric-wieser/numpy_ringbuffer
numpy ringbuffer
Last synced: 14 days ago
JSON representation
Ring-buffer implementation that thinly wraps a numpy array
- Host: GitHub
- URL: https://github.com/eric-wieser/numpy_ringbuffer
- Owner: eric-wieser
- License: mit
- Created: 2016-11-14T13:59:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-03T11:44:10.000Z (about 1 year ago)
- Last Synced: 2024-10-16T11:27:16.229Z (29 days ago)
- Topics: numpy, ringbuffer
- Language: Python
- Homepage: https://pypi.python.org/pypi/numpy_ringbuffer/
- Size: 18.6 KB
- Stars: 87
- Watchers: 10
- Forks: 15
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# numpy_ringbuffer
[![Build Status](https://github.com/eric-wieser/numpy_ringbuffer/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/eric-wieser/numpy_ringbuffer/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/eric-wieser/numpy_ringbuffer/branch/master/graph/badge.svg)](https://codecov.io/gh/eric-wieser/numpy_ringbuffer)Ring (aka circular) buffers backed by a numpy array, supporting:
* Operations from `collections.deque`
* `b.append(val)`
* `b.appendleft(val)`
* `b.extend(val)`
* `b.extendleft(val)`
* `b.pop(val)`
* `b.popleft(val)`
* The `collections.Sequence` protocol (unoptimized)
* C-side unwrapping into an array with `np.array(b)`
* Arbitrary element dtypes, including extra dimensions like `RingBuffer(N, dtype=(int, 3))`For example:
```python
import numpy as np
from numpy_ringbuffer import RingBufferr = RingBuffer(capacity=4, dtype=bool)
r.append(True)
r.appendleft(False)
print(np.array(r)) # array([False, True])
```