Skip to main content

No project description provided

Project description

Replay Memory

Simple replay memory data structure implemented using a ring buffer in Rust. Intended to be used for reinforcement learning.

Installation

pip install replay_memory

Usage

>>> import replay_memory
>>> rm = replay_memory.ReplayMemory(10)  # set capacity to 10
>>> rm.push_items(range(21))
>>> rm[0]  # show has overwritten oldest data
20
>>> len(rm)  # length unchanged
10
>>> rm.sample(3)  # get a randomly selected sample of 3 items
[20, 18, 11]
>>> rm.sample(3)
[12, 18, 16]

Development

Package is written in rust using PyO3 and maturin.

Unit tests

Rust unit tests can be run as below:

cargo test --no-default-features

Python unit tests are run using tox:

tox

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

replay_memory-0.2.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distributions

replay_memory-0.2.0-cp36-abi3-manylinux_2_28_x86_64.whl (205.3 kB view hashes)

Uploaded CPython 3.6+ manylinux: glibc 2.28+ x86-64

replay_memory-0.2.0-cp36-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (481.9 kB view hashes)

Uploaded CPython 3.6+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

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