libenv/libenv.py
def _allocate_dict_space(
        self, num_envs: int, dict_space: gym.spaces.Dict
    ) -> Tuple[collections.OrderedDict, Any]:
        """
        Allocate arrays for a space, returns an OrderedDict of numpy arrays along with a backing bytearray
        """
        result = collections.OrderedDict()  # type: collections.OrderedDict
        length = len(dict_space.spaces) * num_envs
        buffers = self._ffi.new(f"void *[{length}]")
        for space_idx, (name, space) in enumerate(dict_space.spaces.items()):
            actual_shape = (num_envs,) + space.shape
            arr = self._numpy_aligned(shape=actual_shape, dtype=space.dtype)
            result[name] = arr
            for env_idx in range(num_envs):
                buffers[space_idx * num_envs + env_idx] = self._ffi.from_buffer(
                    arr.data[env_idx:]
                )
        return result, buffers

        Allocate arrays for a space, returns an OrderedDict of numpy arrays along with a backing bytearray
        
Allocate arrays for a space, returns an OrderedDict of numpy arrays along with a backing bytearray
Allocate arrays for a space returns an OrderedDict of numpy arrays along with a backing bytearray
def _allocate_dict_space(
        self, num_envs: int, dict_space: gym.spaces.Dict
    ) -> Tuple[collections.OrderedDict, Any]:
        result = collections.OrderedDict()  
        length = len(dict_space.spaces) * num_envs
        buffers = self._ffi.new(f"void *[{length}]")
        for space_idx, (name, space) in enumerate(dict_space.spaces.items()):
            actual_shape = (num_envs,) + space.shape
            arr = self._numpy_aligned(shape=actual_shape, dtype=space.dtype)
            result[name] = arr
            for env_idx in range(num_envs):
                buffers[space_idx * num_envs + env_idx] = self._ffi.from_buffer(
                    arr.data[env_idx:]
                )
        return result, buffers
def _allocate_dict_space ( self , num_envs : int , dict_space : gym . spaces . Dict ) -> Tuple [ collections . OrderedDict , Any ] : result = collections . OrderedDict ( ) length = len ( dict_space . spaces ) * num_envs buffers = self . _ffi . new ( f"void *[{length}]" ) for space_idx , ( name , space ) in enumerate ( dict_space . spaces . items ( ) ) : actual_shape = ( num_envs , ) + space . shape arr = self . _numpy_aligned ( shape = actual_shape , dtype = space . dtype ) result [ name ] = arr for env_idx in range ( num_envs ) : buffers [ space_idx * num_envs + env_idx ] = self . _ffi . from_buffer ( arr . data [ env_idx : ] ) return result , buffers
Allocate arrays for a space, returns an OrderedDict of numpy arrays along with a backing bytearray
Allocate arrays for a space returns an OrderedDict of numpy arrays along with a backing bytearray
"""
        Allocate arrays for a space, returns an OrderedDict of numpy arrays along with a backing bytearray
        """ # type: collections.OrderedDict

self
num_envs
int
dict_space
gym.spaces.Dict