def action_spec(self): """Implements dm_env.Environment.action_spec.""" action_spec = dm_env_utils.dm_env_spec(self._action_specs) if self._nested_tensors: return dm_env_flatten_utils.unflatten_dict(action_spec, DEFAULT_KEY_SEPARATOR) else: return action_spec
def test_spec(self): dm_env_rpc_specs = { 54: dm_env_rpc_pb2.TensorSpec(name='fuzz', shape=[3], dtype=dm_env_rpc_pb2.DataType.FLOAT), 55: dm_env_rpc_pb2.TensorSpec(name='foo', shape=[2], dtype=dm_env_rpc_pb2.DataType.INT32), } manager = spec_manager.SpecManager(dm_env_rpc_specs) expected = { 'foo': specs.Array(shape=[2], dtype=np.int32), 'fuzz': specs.Array(shape=[3], dtype=np.float32) } self.assertDictEqual(expected, dm_env_utils.dm_env_spec(manager))
def test_empty_spec(self): self.assertDictEqual({}, dm_env_utils.dm_env_spec( spec_manager.SpecManager({})))
def action_spec(self): """Implements dm_env.Environment.action_spec.""" return dm_env_utils.dm_env_spec(self._action_specs)