本文整理匯總了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))
示例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
示例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))
示例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))
示例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))