Skip to main content

NDArray with both-side insertion/deletion and size limit

Project description

Coverage badge

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


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)

Uploaded Source

Built Distribution

ndarraybuffer-0.1.2-py3-none-any.whl (4.0 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