(
    sensors: typing.List[sensor.Sensor])
return observation_space
Convert a list of 1D BoxSpaceSensors to the corresponding gym space.

  Args:
    sensors: a list of the current sensors

  Returns:
    space: the converted gym space

  Raises:
    UnsupportedConversionError: raises when the function cannot convert the
      given list of sensors.
    AmbiguousDataTypeError: raises when the function cannot determine the
      data types because they are not uniform.
Convert a list of 1D BoxSpaceSensors to the corresponding gym space.
Convert a list of 1D BoxSpaceSensors to the corresponding gym space .
def convert_1d_box_sensors_to_gym_space(
    sensors: typing.List[sensor.Sensor]) -> gym.Space:
  """Convert a list of 1D BoxSpaceSensors to the corresponding gym space.

  Args:
    sensors: a list of the current sensors

  Returns:
    space: the converted gym space

  Raises:
    UnsupportedConversionError: raises when the function cannot convert the
      given list of sensors.
    AmbiguousDataTypeError: raises when the function cannot determine the
      data types because they are not uniform.
  """
  # Check if all sensors are 1D BoxSpaceSensors
  if not all([
      isinstance(s, sensor.BoxSpaceSensor) and s.get_dimension() == 1
      for s in sensors
  ]):
    raise UnsupportedConversionError('sensors = ' + str(sensors))

  # Check if all sensors have the same data type
  sensor_dtypes = [s.get_dtype() for s in sensors]
  if sensor_dtypes.count(sensor_dtypes[0]) != len(sensor_dtypes):
    raise AmbiguousDataTypeError('sensor datatypes are inhomogeneous')

  lower_bound = np.concatenate([s.get_lower_bound() for s in sensors])
  upper_bound = np.concatenate([s.get_upper_bound() for s in sensors])
  observation_space = spaces.Box(np.array(lower_bound),
                                 np.array(upper_bound),
                                 dtype=np.float32)
  return observation_space
def convert_1d_box_sensors_to_gym_space ( sensors : typing . List [ sensor . Sensor ] ) -> gym . Space : # Check if all sensors are 1D BoxSpaceSensors if not all ( [ isinstance ( s , sensor . BoxSpaceSensor ) and s . get_dimension ( ) == 1 for s in sensors ] ) : raise UnsupportedConversionError ( 'sensors = ' + str ( sensors ) ) # Check if all sensors have the same data type sensor_dtypes = [ s . get_dtype ( ) for s in sensors ] if sensor_dtypes . count ( sensor_dtypes [ 0 ] ) != len ( sensor_dtypes ) : raise AmbiguousDataTypeError ( 'sensor datatypes are inhomogeneous' ) lower_bound = np . concatenate ( [ s . get_lower_bound ( ) for s in sensors ] ) upper_bound = np . concatenate ( [ s . get_upper_bound ( ) for s in sensors ] ) observation_space = spaces . Box ( np . array ( lower_bound ) , np . array ( upper_bound ) , dtype = np . float32 ) return observation_space