-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasics.py
40 lines (29 loc) · 834 Bytes
/
basics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from replaybuffer import ReplayBuffer
from replaybuffer.utils import remove_nones
def main():
buffer = ReplayBuffer(max_size=100)
buffer.initialize_buffer("stream_1")
buffer.initialize_buffer("stream_2")
print("Initial state")
print(buffer.previous(n=10))
print()
buffer.store(stream_1=1, stream_2="some other data")
print("After adding one element")
print(buffer.previous(n=10))
print()
print("Cleaned up")
prev = buffer.previous(n=10)
s1, s2 = remove_nones(*prev.values())
print(s1)
print(s2)
print()
print("Sampling")
for i in range(100):
buffer.store(stream_1=i, stream_2=i + 1)
print(buffer.sample(n=10))
print()
print("Taking")
print(buffer.take(range(0, 5)))
print(buffer[0:5])
if __name__ == "__main__":
main()