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.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for ndarraybuffer-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0e2333a102757fec86f34832294d8514033f762395dd8f34f8ae70241060dae |
|
MD5 | 63aaa528f2bec54808feecce7a17ac44 |
|
BLAKE2b-256 | 6b69c34e4e5fe69dee31d684d4060438b9bfdc7abee345e1eefbd30ec06bed24 |