docstr: Tests if adding timestep data to a `SingleAgentEpisode` works.
  
  Adding timestep data is the central part of collecting episode
  dara. Here it is tested if adding to the internal data lists
  works as intended and the timestep is increased during each step.
docstr_tok: ["Tests","if","adding","timestep","data","to","a","`","SingleAgentEpisode","`","works",".","Adding","timestep","data","is","the","central","part","of","collecting","episode","dara",".","Here","it","is","tested","if","adding","to","the","internal","data","lists","works","as","intended","and","the","timestep","is","increased","during","each","step","."]
code: def test_add_env_step(self):
      """Tests if adding timestep data to a `SingleAgentEpisode` works.
  
      Adding timestep data is the central part of collecting episode
      dara. Here it is tested if adding to the internal data lists
      works as intended and the timestep is increased during each step.
      """
      # Create an empty episode and add initial observations.
      episode = SingleAgentEpisode()
      env = gym.make("CartPole-v1")
      # Set the random seed (otherwise the episode will terminate at
      # different points in each test run).
      obs, info = env.reset(seed=0)
      episode.add_env_reset(observation=obs, infos=info)
  
      # Sample 100 timesteps and add them to the episode.
      terminated = truncated = False
      for i in range(100):
          action = env.action_space.sample()
          obs, reward, terminated, truncated, info = env.step(action)
          episode.add_env_step(
              observation=obs,
              action=action,
              reward=reward,
              infos=info,
              terminated=terminated,
              truncated=truncated,
              extra_model_outputs={"extra": np.random.random(1)},
          )
          if terminated or truncated:
              break
  
      # Assert that the episode timestep is at 100.
      self.assertTrue(
          episode.t == len(episode.observations) - 1 == i + 1
      )
      # Assert that `t_started` stayed at zero.
      self.assertTrue(episode.t_started == 0)
      # Assert that all lists have the proper lengths.
      self.assertTrue(
          len(episode.actions)
          == len(episode.rewards)
          == len(episode.observations) - 1
          == len(episode.infos) - 1
          == i + 1
      )
      # Assert that the flags are set correctly.
      self.assertTrue(episode.is_terminated == terminated)
      self.assertTrue(episode.is_truncated == truncated)
      self.assertTrue(episode.is_done == terminated or truncated)
  
imports: from collections import defaultdict
  from typing import Any, Dict, Optional, SupportsFloat, Tuple
  import unittest
  import gymnasium
  from gymnasium.core import ActType, ObsType
  import numpy
  from ray.rllib.env.single_agent_episode import SingleAgentEpisode
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 3 for calling the TestSingelAgentEpisode obj's underlying member method code with example usage: obj.test_add_env_step() without return types