(self)
Gets the current observation.

    The returned observation is only valid as of the previous call
    to `reset`. In particular, it is an error to call this function before
    the first call to `reset`.

    Returns:
      A dict, or list of dicts, or tuple of dicts, of observation values.
      The returned structure corresponds to the structure of the `observables`
      that was given at initialization time.

    Raises:
      RuntimeError: If this method is called before `reset` has been called.
Gets the current observation.
Gets the current observation .
def get_observation(self):
    """Gets the current observation.

    The returned observation is only valid as of the previous call
    to `reset`. In particular, it is an error to call this function before
    the first call to `reset`.

    Returns:
      A dict, or list of dicts, or tuple of dicts, of observation values.
      The returned structure corresponds to the structure of the `observables`
      that was given at initialization time.

    Raises:
      RuntimeError: If this method is called before `reset` has been called.
    """
    if self._enabled_structure is None:
      raise RuntimeError('`reset` must be called before `observation`.')

    def aggregate_dict(enabled_dict):
      out_dict = type(enabled_dict)()
      for name, enabled in enabled_dict.items():
        if enabled.observable.aggregator:
          aggregated = enabled.observable.aggregator(
              enabled.buffer.read(self._step_counter))
        else:
          aggregated = enabled.buffer.read(self._step_counter)
        out_dict[name] = aggregated
      return out_dict

    if self._is_nested:
      return type(self._enabled_structure)(
          aggregate_dict(enabled_dict)
          for enabled_dict in self._enabled_structure)
    else:
      return aggregate_dict(self._enabled_structure)
def get_observation ( self ) : if self . _enabled_structure is None : raise RuntimeError ( '`reset` must be called before `observation`.' ) def aggregate_dict ( enabled_dict ) : out_dict = type ( enabled_dict ) ( ) for name , enabled in enabled_dict . items ( ) : if enabled . observable . aggregator : aggregated = enabled . observable . aggregator ( enabled . buffer . read ( self . _step_counter ) ) else : aggregated = enabled . buffer . read ( self . _step_counter ) out_dict [ name ] = aggregated return out_dict if self . _is_nested : return type ( self . _enabled_structure ) ( aggregate_dict ( enabled_dict ) for enabled_dict in self . _enabled_structure ) else : return aggregate_dict ( self . _enabled_structure )