Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e6b0a40
New Step API with terminated, truncated bools instead of done
arjun-kg Apr 14, 2022
6618da5
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Apr 20, 2022
a0c4475
Setting return_two_dones=False as default
arjun-kg Apr 20, 2022
2aabc30
update warnings
arjun-kg Apr 20, 2022
1babe4e
pytest - ignore deprecation warnings
arjun-kg Apr 21, 2022
c9c6add
Only ignore step api deprecation warnings
arjun-kg Apr 21, 2022
c5fe53c
fix duplicate wrapping bug in vector envs
arjun-kg Apr 21, 2022
f88927d
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Apr 22, 2022
7c1e9c7
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Apr 25, 2022
6af7182
edit docstrings, comments, warnings
arjun-kg Apr 25, 2022
22c1cc7
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg May 3, 2022
68ef969
step compatibility for wrappers, vectors
arjun-kg May 4, 2022
f06343b
reset tests back to old api
arjun-kg May 4, 2022
794737b
fix circular import
arjun-kg May 4, 2022
f89e5da
merge tests with master
arjun-kg May 4, 2022
8b518bb
existing code, tests work
arjun-kg May 5, 2022
9a2a9af
fix compat at registration, tests
arjun-kg May 5, 2022
29eafe5
docstrings, tests passing
arjun-kg May 5, 2022
63fc044
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg May 28, 2022
97f36d3
dealing with conflicts
arjun-kg May 28, 2022
63d3d19
update wrapper class to use step compatibility
arjun-kg May 28, 2022
492c6e1
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 2, 2022
9ce03cb
add warning for play
arjun-kg Jun 2, 2022
f93295f
add todo
arjun-kg Jun 2, 2022
1940494
replace 'closing' with 'final'
arjun-kg Jun 2, 2022
f12b5fb
fix pre-commit
arjun-kg Jun 2, 2022
aa5a071
remove previously missed `done` references
arjun-kg Jun 3, 2022
e135b9e
fix step compat in atari wrapper reset
arjun-kg Jun 3, 2022
2bb742a
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 7, 2022
1f11077
fix tests with step returning np.bool_
arjun-kg Jun 7, 2022
e861fbc
remove warning for using new api
arjun-kg Jun 7, 2022
fe04e7c
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 8, 2022
8e56f45
pre-commit fixes
arjun-kg Jun 8, 2022
4491d9a
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 9, 2022
be947e3
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 20, 2022
5e8f085
new API does not include 'TimeLimit.truncated' in info
arjun-kg Jun 20, 2022
cdb3516
fix checks, tests
arjun-kg Jun 20, 2022
8cc2074
vector info mask - fix wrong underscore
arjun-kg Jun 20, 2022
2f83d55
dont remove from info
arjun-kg Jun 21, 2022
57e839c
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jun 21, 2022
b1660cf
edit definitions
arjun-kg Jun 21, 2022
ea10e7a
remove whitespaces :/
arjun-kg Jun 21, 2022
bffa257
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jul 3, 2022
d7dff2c
update tests
arjun-kg Jul 3, 2022
b2c10a4
fix pattern
arjun-kg Jul 3, 2022
6553bed
restructure warnings
arjun-kg Jul 4, 2022
50d367e
fix incorrect warning
arjun-kg Jul 4, 2022
d71836f
fix incorrect warnings (properly)
arjun-kg Jul 4, 2022
78a507e
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jul 4, 2022
a747625
add warning to env checker
arjun-kg Jul 5, 2022
28c7b36
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jul 5, 2022
d65d21b
Merge branch 'master' of https://github.com/openai/gym into done_term…
arjun-kg Jul 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests with step returning np.bool_
  • Loading branch information
arjun-kg committed Jun 7, 2022
commit 1f11077ea84fabdfd7a800bad58881870cd6343d
2 changes: 1 addition & 1 deletion gym/envs/mujoco/inverted_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def step(self, a):
reward = 1.0
self.do_simulation(a, self.frame_skip)
ob = self._get_obs()
terminated = not np.isfinite(ob).all() or (np.abs(ob[1]) > 0.2)
terminated = bool(not np.isfinite(ob).all() or (np.abs(ob[1]) > 0.2))
return ob, reward, terminated, False, {}

def reset_model(self):
Expand Down
2 changes: 1 addition & 1 deletion gym/envs/mujoco/inverted_pendulum_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def step(self, a):
reward = 1.0
self.do_simulation(a, self.frame_skip)
ob = self._get_obs()
terminated = not np.isfinite(ob).all() or (np.abs(ob[1]) > 0.2)
terminated = bool(not np.isfinite(ob).all() or (np.abs(ob[1]) > 0.2))
return ob, reward, terminated, False, {}

def reset_model(self):
Expand Down
18 changes: 7 additions & 11 deletions gym/envs/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import numpy as np

from gym.envs.__relocated__ import internal_env_relocation_map
from gym.wrappers import AutoResetWrapper, OrderEnforcing, StepAPICompatibility, TimeLimit
from gym.wrappers import (
AutoResetWrapper,
OrderEnforcing,
StepAPICompatibility,
TimeLimit,
)
from gym.wrappers.env_checker import PassiveEnvChecker

if sys.version_info < (3, 10):
Expand Down Expand Up @@ -602,7 +607,7 @@ def make(
# Run the environment checker as the lowest level wrapper
if disable_env_checker is False:
env = PassiveEnvChecker(env)

env = StepAPICompatibility(env, new_step_api)

# Add the order enforcing wrapper
Expand All @@ -619,15 +624,6 @@ def make(
if autoreset:
env = AutoResetWrapper(env, new_step_api)

if not disable_env_checker:
try:
check_env(env)
except Exception as e:
logger.warn(
f"Env check failed with the following message: {e}\n"
f"You can set `disable_env_checker=True` to disable this check."
)

return env


Expand Down
1 change: 0 additions & 1 deletion gym/utils/env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
passive_env_reset_check,
passive_env_step_check,
)
from gym.utils.step_api_compatibility import step_api_compatibility


def data_equivalence(data_1, data_2) -> bool:
Expand Down
12 changes: 9 additions & 3 deletions gym/utils/passive_env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,18 @@ def passive_env_step_check(env, action):
if len(result) == 4:
obs, reward, done, info = result

assert isinstance(done, bool), "The `done` signal must be a boolean"
assert isinstance(
done, bool
), f"The `done` signal is of type `{type(done)}` must be a boolean"
elif len(result) == 5:
obs, reward, terminated, truncated, info = result

assert isinstance(terminated, bool), "The `terminated` signal must be a boolean"
assert isinstance(truncated, bool), "The `truncated` signal must be a boolean"
assert isinstance(
terminated, bool
), f"The `terminated` signal is of type `{type(terminated)}`. It must be a boolean"
assert isinstance(
truncated, bool
), f"The `truncated` signal of type `{type(truncated)}`. It must be a boolean."
assert (
terminated is False or truncated is False
), "Only `terminated` or `truncated` can be true, not both."
Expand Down
11 changes: 9 additions & 2 deletions gym/vector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def create_env(_disable_env_checker):

def _make_env():
env = gym.envs.registration.make(
id, disable_env_checker=_disable_env_checker, new_step_api=True, **kwargs
id,
disable_env_checker=_disable_env_checker,
new_step_api=True,
**kwargs,
)
if wrappers is not None:
if callable(wrappers):
Expand All @@ -68,4 +71,8 @@ def _make_env():
create_env(env_num == 0 and disable_env_checker is False)
for env_num in range(num_envs)
]
return AsyncVectorEnv(env_fns, new_step_api=new_step_api) if asynchronous else SyncVectorEnv(env_fns, new_step_api=new_step_api)
return (
AsyncVectorEnv(env_fns, new_step_api=new_step_api)
if asynchronous
else SyncVectorEnv(env_fns, new_step_api=new_step_api)
)