NDArray with both-side insertion/deletion and size limit
Project description
Introduction
Wrap numpy.ndarray
to support fast both-side insertion/deletion and size limit.
- Fully typed.
- Directly perform arithmetic operations with NDArray
- pickleable
- JSON serializable
pip install ndarraybuffer
Both-side insertion/deletion
arr = ArrayBuffer()
arr.extend(np.arange(100))
arr.append(100)
arr.appendleft(0)
arr.pop(1)
arr.popleft(1)
Size limit
arr = ArrayBuffer(max_len=10)
arr.extend(np.arange(10))
assert len(arr) == 10
assert np.array_equal(arr, np.arange(10))
arr.append(10)
assert len(arr) == 10
assert np.array_equal(arr, np.arange(1, 11))
JSON Serialization and Deserialization
arr = ArrayBuffer(max_len=10, dtype=np.float64)
arr.extend(np.arange(10))
state_dict = arr.state_dict()
rec = ArrayBuffer.load(json.loads(json.dumps(state_dict)))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ndarraybuffer-0.1.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for ndarraybuffer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77675cb94b9aed1a890d646d19f65843d572fc7774e9186ed7f53d7c5f855592 |
|
MD5 | 0cdd56e2cdbfd4f7d02f4f9e5cbf4276 |
|
BLAKE2b-256 | 6f3b95c2201ade413bbb27c4969264c94c008b1b744f77a258c2b5121118c369 |