class_docstr: The DiscretizeActionsWrapper provides functionality for discretizing individual continuous actions into discrete
   ones.
  
  An example is given by having a continuous action called 'action_up' with space:
  gym.spaces.Box(shape=(5,), low=[-1,-1,-1,-1,-1], high=[1,1,1,1,1]
  
  discretization_config:
      action_up:
          num_bins: 5
          low: [-1, 0, 0.5, 0, 0]
          high: 1
  
  Now the action space will be split where each of the 5 continuous values of the box spaces are split evenly within
  the ranges of (-1,1),(0,1),(0.5,1), (0,1), (0,1) respectively.
  
  :param env: Environment/wrapper to wrap.
  :param discretization_config: The action discretization configuration.
class_docstr_tok: ["The","DiscretizeActionsWrapper","provides","functionality","for","discretizing","individual","continuous","actions","into","discrete","ones",".","An","example","is","given","by","having","a","continuous","action","called","'action_up","'","with","space",":","gym.spaces.Box","(","shape=","(","5",",",")",",","low=","[","-1",",","-1",",","-1",",","-1",",","-1","]",",","high=","[","1,1,1,1,1","]","discretization_config",":","action_up",":","num_bins",":","5","low",":","[","-1",",","0",",","0.5",",","0",",","0","]","high",":","1","Now","the","action","space","will","be","split","where","each","of","the","5","continuous","values","of","the","box","spaces","are","split","evenly","within","the","ranges","of","(","-1,1",")",",","(","0,1",")",",","(","0.5,1",")",",","(","0,1",")",",","(","0,1",")","respectively",".",":","param","env",":","Environment\/wrapper","to","wrap",".",":","param","discretization_config",":","The","action","discretization","configuration","."]
docstr: Test the config for inconsistencies or incomplete definitions.
  
  :param discretization_config: The action discretization configuration.
docstr_tok: ["Test","the","config","for","inconsistencies","or","incomplete","definitions",".",":","param","discretization_config",":","The","action","discretization","configuration","."]
code: def _test_config(
      self,
      discretization_config: Dict[
          str,
          Dict[str, Union[Union[int, float], List[Union[int, float]]]],
      ],
  ) -> None:
      """Test the config for inconsistencies or incomplete definitions.
  
      :param discretization_config: The action discretization configuration.
      """
  
      for action_key, config in discretization_config.items():
          # Assert key is present in action space
          flat_action_space = flat_structured_space(
              self.env.action_spaces_dict
          )
          assert (
              action_key in flat_action_space.spaces.keys()
          ), f"{action_key} not in {flat_action_space}"
          assert isinstance(
              flat_action_space[action_key], gym.spaces.Box
          )
          assert len(flat_action_space[action_key].shape) == 1, (
              "Only single dimensional continuous spaces supported. Please use the SplitActionWrapper in order to "
              "split the actions first."
          )
          assert "num_bins" in config
          assert (
              config["num_bins"] > 1
          ), "Num of bins must be greater than 1"
          if "low" in config:
              assert "high" in config
              if isinstance(
                  config["low"], (float, int)
              ) and not isinstance(config["high"], (float, int)):
                  high = np.array(config["high"])
                  low = np.array([config["low"]] * len(high))
              elif isinstance(
                  config["high"], (float, int)
              ) and not isinstance(config["low"], (float, int)):
                  low = np.array(config["low"])
                  high = np.array([config["high"]] * len(low))
              else:
                  low = config["low"]
                  high = config["high"]
                  if not isinstance(low, (float, int)):
                      assert len(low) == len(high)
              assert np.all(low < high), (
                  f"lower bound must be smaller than higher bound (low: {low}, high: {high}"
                  f", action_key: {action_key})"
              )
              assert np.all(low >= flat_action_space[action_key].low), (
                  f"Lower bound has to be larger or equal to the lower bound of the original space (low: {low}, "
                  f"original space low: {flat_action_space[action_key].low}, action_key: {action_key})"
              )
              assert np.all(
                  high <= flat_action_space[action_key].high
              ), (
                  f"Higher bound has to be smaller or equal to the higher bound of the original space (high: {high}"
                  f", original space high: {flat_action_space[action_key].high}, action_key: {action_key})"
              )
  
file_path: maze/maze/core/wrappers/discretize_actions_wrapper.py
imports: from typing import Union, Dict, List
  import gym
  import numpy
  from maze.core.annotations import override
  from maze.core.env.simulated_env_mixin import SimulatedEnvMixin
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.env.structured_env_spaces_mixin import StructuredEnvSpacesMixin
  from maze.core.utils.structured_env_utils import flat_structured_space
  from maze.core.wrappers.wrapper import ActionWrapper, EnvType
label_desc: Use image node_id 2 for calling the DiscretizeActionsWrapper obj's underlying member method code with example usage: obj._test_config(discretization_config) without return types