docstr: Tests adding, sampling, get-/set state, and eviction with
  experiences stored by timesteps.
code: def test_timesteps_unit(self):
      """Tests adding, sampling, get-/set state, and eviction with
      experiences stored by timesteps.
      """
      self.batch_id = 0
  
      batch_size = 5
      buffer_size = 15
  
      buffer = ReplayBuffer(capacity=buffer_size)
  
      # Test add/sample
      self._add_data_to_buffer(
          buffer, batch_size=batch_size, num_batches=1
      )
  
      self._add_data_to_buffer(
          buffer, batch_size=batch_size, num_batches=2
      )
  
      # Sampling from it now should yield our first batch 1/3 of the time
      num_sampled_dict = {_id: 0 for _id in range(self.batch_id)}
      num_samples = 200
      for i in range(num_samples):
          _id = buffer.sample(1)["batch_id"][0]
          num_sampled_dict[_id] += 1
      assert np.allclose(
          np.array(list(num_sampled_dict.values())) / num_samples,
          len(num_sampled_dict) * [1 / 3],
          atol=0.1,
      )
  
      # Test set/get state
      state = buffer.get_state()
      other_buffer = ReplayBuffer(capacity=buffer_size)
      self._add_data_to_buffer(other_buffer, 1)
      other_buffer.set_state(state)
  
      assert other_buffer._storage == buffer._storage
      assert other_buffer._next_idx == buffer._next_idx
      assert (
          other_buffer._num_timesteps_added
          == buffer._num_timesteps_added
      )
      assert (
          other_buffer._num_timesteps_added_wrap
          == buffer._num_timesteps_added_wrap
      )
      assert (
          other_buffer._num_timesteps_sampled
          == buffer._num_timesteps_sampled
      )
      assert other_buffer._eviction_started == buffer._eviction_started
      assert other_buffer._est_size_bytes == buffer._est_size_bytes
      assert len(other_buffer) == len(other_buffer)
  
file_path: ray/rllib/utils/replay_buffers/tests/test_replay_buffer.py
imports: import unittest
  import numpy
  from ray.rllib.policy.sample_batch import SampleBatch, MultiAgentBatch, concat_samples
  from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer
label_desc: Use image node_id 4 for calling the TestReplayBuffer obj's underlying member method code with example usage: obj.test_timesteps_unit() without return types