code: def test_box():
      # simple action space
      action_space = BoxActionSpace(4, -5, 5, ["a", "b", "c", "d"])
      for i in range(100):
          sample = action_space.sample()
          assert np.all(-5 <= sample) and np.all(sample <= 5)
          assert sample.shape == (4,)
          assert sample.dtype == float
  
      # test clipping
      clipped_action = action_space.clip_action_to_space(
          np.array([-10, 10, 2, 5])
      )
      assert np.all(clipped_action == np.array([-5, 5, 2, 5]))
  
      # more complex high and low definition
      action_space = BoxActionSpace(
          4,
          np.array([-5, -1, -0.5, 0]),
          np.array([1, 2, 4, 5]),
          ["a", "b", "c", "d"],
      )
      for i in range(100):
          sample = action_space.sample()
          assert np.all(
              np.array([-5, -1, -0.5, 0]) <= sample
          ) and np.all(sample <= np.array([1, 2, 4, 5]))
          assert sample.shape == (4,)
          assert sample.dtype == float
  
      # test clipping
      clipped_action = action_space.clip_action_to_space(
          np.array([-10, 10, 2, 5])
      )
      assert np.all(clipped_action == np.array([-5, 2, 2, 5]))
  
      # mixed high and low definition
      action_space = BoxActionSpace(
          4, np.array([-5, -1, -0.5, 0]), 5, ["a", "b", "c", "d"]
      )
      for i in range(100):
          sample = action_space.sample()
          assert np.all(
              np.array([-5, -1, -0.5, 0]) <= sample
          ) and np.all(sample <= 5)
          assert sample.shape == (4,)
          assert sample.dtype == float
  
      # test clipping
      clipped_action = action_space.clip_action_to_space(
          np.array([-10, 10, 2, 5])
      )
      assert np.all(clipped_action == np.array([-5, 5, 2, 5]))
  
      # invalid bounds
      with pytest.raises(ValueError):
          action_space = BoxActionSpace(
              4, np.array([-5, -1, -0.5, 0]), -1, ["a", "b", "c", "d"]
          )
  
file_path: coach/rl_coach/tests/test_spaces.py
imports: import os
  import sys
  import pytest
  from rl_coach.spaces import DiscreteActionSpace, BoxActionSpace, MultiSelectActionSpace, ObservationSpace, AgentSelection, VectorObservationSpace, AttentionActionSpace
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: test_box() without return types