当前位置: 首页>>代码示例>>Python>>正文


Python error.DeprecatedEnv方法代码示例

本文整理汇总了Python中gym.error.DeprecatedEnv方法的典型用法代码示例。如果您正苦于以下问题:Python error.DeprecatedEnv方法的具体用法?Python error.DeprecatedEnv怎么用?Python error.DeprecatedEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gym.error的用法示例。


在下文中一共展示了error.DeprecatedEnv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: spec

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import DeprecatedEnv [as 别名]
def spec(self, id):
        # +-+--+-+-+-+ PATCHING --+-+-+-+-+-+
        _self = gym.envs.registry
        # +-+--+-+-+-+ /PATCHING --+-+-+-+-+-+
        match = env_id_re.search(id)
        if not match:
            raise error.Error('Attempted to look up malformed environment ID: {}. (Currently all IDs must be of the form {}.)'.format(id.encode('utf-8'), env_id_re.pattern))

        try:
            return _self.env_specs[id]
        except KeyError:
            # Parse the env name and check to see if it matches the non-version
            # part of a valid env (could also check the exact number here)
            env_name = match.group(1)
            matching_envs = [valid_env_name for valid_env_name, valid_env_spec in _self.env_specs.items()
                             if env_name == valid_env_spec._env_name]
            if matching_envs:
                raise error.DeprecatedEnv('Env {} not found (valid versions include {})'.format(id, matching_envs))
            else:
                raise error.UnregisteredEnv('No registered env with id: {}'.format(id)) 
开发者ID:ppaquette,项目名称:gym-pull,代码行数:22,代码来源:registration.py

示例2: test_missing_lookup

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import DeprecatedEnv [as 别名]
def test_missing_lookup():
    registry = registration.EnvRegistry()
    registry.register(id='Test-v0', entry_point=None)
    registry.register(id='Test-v15', entry_point=None)
    registry.register(id='Test-v9', entry_point=None)
    registry.register(id='Other-v100', entry_point=None)
    try:
        registry.spec('Test-v1')  # must match an env name but not the version above
    except error.DeprecatedEnv:
        pass
    else:
        assert False

    try:
        registry.spec('Unknown-v1')
    except error.UnregisteredEnv:
        pass
    else:
        assert False 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:21,代码来源:test_registration.py

示例3: spec

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import DeprecatedEnv [as 别名]
def spec(self, id):
        match = env_id_re.search(id)
        if not match:
            raise error.Error('Attempted to look up malformed environment ID: {}. (Currently all IDs must be of the form {}.)'.format(id.encode('utf-8'), env_id_re.pattern))

        try:
            return self.env_specs[id]
        except KeyError:
            # Parse the env name and check to see if it matches the non-version
            # part of a valid env (could also check the exact number here)
            env_name = match.group(1)
            matching_envs = [valid_env_name for valid_env_name, valid_env_spec in self.env_specs.items()
                             if env_name == valid_env_spec._env_name]
            if matching_envs:
                raise error.DeprecatedEnv('Env {} not found (valid versions include {})'.format(id, matching_envs))
            else:
                raise error.UnregisteredEnv('No registered env with id: {}'.format(id)) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:19,代码来源:registration.py

示例4: spec

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import DeprecatedEnv [as 别名]
def spec(self, id):
        match = agent_id_re.search(id)
        if not match:
            raise error.Error('Attempted to look up malformed agent ID: {}. (Currently all IDs must be of the form {}.)'.format(id.encode('utf-8'), agent_id_re.pattern))

        try:
            return self.agent_specs[id]
        except KeyError:
            # Parse the agent name and check to see if it matches the non-version
            # part of a valid agent (could also check the exact number here)
            agent_name = match.group(1)
            matching_agents = [valid_agent_name for valid_agent_name, valid_agent_spec in self.agent_specs.items()
                             if agent_name == valid_agent_spec._agent_name]
            if matching_agents:
                raise error.DeprecatedEnv('Agent {} not found (valid versions include {})'.format(id, matching_agents))
            else:
                raise error.UnregisteredEnv('No registered agent with id: {}'.format(id)) 
开发者ID:benelot,项目名称:bullet-gym,代码行数:19,代码来源:agent_register.py

示例5: spec

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import DeprecatedEnv [as 别名]
def spec(self, path):
        if ':' in path:
            mod_name, _sep, id = path.partition(':')
            try:
                importlib.import_module(mod_name)
            # catch ImportError for python2.7 compatibility
            except ImportError:
                raise error.Error('A module ({}) was specified for the environment but was not found, make sure the package is installed with `pip install` before calling `gym.make()`'.format(mod_name))
        else:
            id = path

        match = env_id_re.search(id)
        if not match:
            raise error.Error('Attempted to look up malformed environment ID: {}. (Currently all IDs must be of the form {}.)'.format(id.encode('utf-8'), env_id_re.pattern))

        try:
            return self.env_specs[id]
        except KeyError:
            # Parse the env name and check to see if it matches the non-version
            # part of a valid env (could also check the exact number here)
            env_name = match.group(1)
            matching_envs = [valid_env_name for valid_env_name, valid_env_spec in self.env_specs.items()
                             if env_name == valid_env_spec._env_name]
            if matching_envs:
                raise error.DeprecatedEnv('Env {} not found (valid versions include {})'.format(id, matching_envs))
            else:
                raise error.UnregisteredEnv('No registered env with id: {}'.format(id)) 
开发者ID:hust512,项目名称:DQN-DDPG_Stock_Trading,代码行数:29,代码来源:registration.py


注:本文中的gym.error.DeprecatedEnv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。