(self, buffer_size, shape, dtype, pad_with_initial_value=False,
               strip_singleton_buffer_dim=False)
Initializes this observation buffer.

    Args:
      buffer_size: The size of the buffer returned by `read`. Note
        that this does *not* affect size of the internal buffer held by this
        object, which always grow as large as is necessary in the presence of
        large delays.
      shape: The shape of a single observation held by this buffer, which can
        either be a single integer or an iterable of integers. The shape of the
        buffer returned by `read` will then be
        `(buffer_size, shape[0], ..., shape[n])`, unless `buffer_size == 1`
        and `strip_singleton_buffer_dim == True`.
      dtype: The NumPy dtype of observation entries.
      pad_with_initial_value: (optional) A boolean. If `True` then the buffer
        returned by `read` is padded with the first observation value when there
        are fewer observation entries than `buffer_size`. If `False` then the
        buffer returned by `read` is padded with zeroes.
      strip_singleton_buffer_dim: (optional) A boolean, if `True` and
        `buffer_size == 1` then the leading dimension will not be added to the
        shape of the array returned by `read`.
Initializes this observation buffer.
Initializes this observation buffer .
def __init__(self, buffer_size, shape, dtype, pad_with_initial_value=False,
               strip_singleton_buffer_dim=False):
    """Initializes this observation buffer.

    Args:
      buffer_size: The size of the buffer returned by `read`. Note
        that this does *not* affect size of the internal buffer held by this
        object, which always grow as large as is necessary in the presence of
        large delays.
      shape: The shape of a single observation held by this buffer, which can
        either be a single integer or an iterable of integers. The shape of the
        buffer returned by `read` will then be
        `(buffer_size, shape[0], ..., shape[n])`, unless `buffer_size == 1`
        and `strip_singleton_buffer_dim == True`.
      dtype: The NumPy dtype of observation entries.
      pad_with_initial_value: (optional) A boolean. If `True` then the buffer
        returned by `read` is padded with the first observation value when there
        are fewer observation entries than `buffer_size`. If `False` then the
        buffer returned by `read` is padded with zeroes.
      strip_singleton_buffer_dim: (optional) A boolean, if `True` and
        `buffer_size == 1` then the leading dimension will not be added to the
        shape of the array returned by `read`.
    """
    self._buffer_size = buffer_size
    try:
      shape = tuple(shape)
    except TypeError:
      if isinstance(shape, int):
        shape = (shape,)
      else:
        raise

    self._has_buffer_dim = not (strip_singleton_buffer_dim and buffer_size == 1)
    if self._has_buffer_dim:
      self._buffered_shape = (buffer_size,) + shape
    else:
      self._buffered_shape = shape
    self._dtype = dtype

    # The "arrived" deque contains entries that are due to be delivered now.
    # This deque should never grow beyond buffer_size.
    self._arrived_deque = collections.deque(maxlen=buffer_size)
    if not pad_with_initial_value:
      for _ in range(buffer_size):
        self._arrived_deque.append(
            InFlightObservation(-np.inf, 0, np.full(shape, 0, dtype)))

    # The "pending" deque contains entries that are stored for future delivery.
    # This deque can grow arbitrarily large in presence of long delays.
    self._pending_deque = collections.deque()
def __init__ ( self , buffer_size , shape , dtype , pad_with_initial_value = False , strip_singleton_buffer_dim = False ) : self . _buffer_size = buffer_size try : shape = tuple ( shape ) except TypeError : if isinstance ( shape , int ) : shape = ( shape , ) else : raise self . _has_buffer_dim = not ( strip_singleton_buffer_dim and buffer_size == 1 ) if self . _has_buffer_dim : self . _buffered_shape = ( buffer_size , ) + shape else : self . _buffered_shape = shape self . _dtype = dtype # The "arrived" deque contains entries that are due to be delivered now. # This deque should never grow beyond buffer_size. self . _arrived_deque = collections . deque ( maxlen = buffer_size ) if not pad_with_initial_value : for _ in range ( buffer_size ) : self . _arrived_deque . append ( InFlightObservation ( - np . inf , 0 , np . full ( shape , 0 , dtype ) ) ) # The "pending" deque contains entries that are stored for future delivery. # This deque can grow arbitrarily large in presence of long delays. self . _pending_deque = collections . deque ( )