code: def test_append_and_sample(self, capacity):
      rbuf = PersistentEpisodicReplayBuffer(self.tempdir.name, capacity)
      assert len(rbuf) == 0
  
      for n in [10, 15, 5] * 3:
          transs = [
              dict(
                  state=i,
                  action=100 + i,
                  reward=200 + i,
                  next_state=i + 1,
                  next_action=101 + i,
                  is_state_terminal=(i == n - 1),
              )
              for i in range(n)
          ]
          for trans in transs:
              rbuf.append(**trans)
  
      assert len(rbuf) == 90
      assert rbuf.n_episodes == 9
  
      for k in [10, 30, 90]:
          s = rbuf.sample(k)
          assert len(s) == k
  
      for k in [1, 3, 9]:
          s = rbuf.sample_episodes(k)
          assert len(s) == k
  
          s = rbuf.sample_episodes(k, max_len=10)
          for ep in s:
              assert len(ep) <= 10
              for t0, t1 in zip(ep, ep[1:]):
                  assert t0["next_state"] == t1["state"]
                  assert t0["next_action"] == t1["action"]
  
file_path: pfrl/tests/replay_buffers_test/test_persistent_replay_buffer.py
imports: import os
  import tempfile
  import pytest
  from pfrl.replay_buffers import PersistentEpisodicReplayBuffer
label_desc: Use image node_id 3 for calling the TestEpisodicReplayBuffer obj's underlying member method code with example usage: obj.test_append_and_sample(capacity) without return types