drop copying the env

This commit is contained in:
Quentin GALLOUÉDEC 2023-06-01 14:33:16 +02:00
parent f60d6e2f91
commit fc9b0672c9

View file

@ -380,6 +380,8 @@ def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -
It also optionally check that the environment is compatible with Stable-Baselines.
Note that this function eventually calls the close the environment.
:param env: The Gym environment that will be checked
:param warn: Whether to output additional warnings
mainly related to the interaction with Stable Baselines
@ -449,12 +451,8 @@ def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -
pass
# Finally, check that the allows calling `close()` even if the environment was already closed
if env.spec is not None:
new_env = env.spec.make()
new_env.close()
try:
new_env.close()
except Exception as e:
warnings.warn(
f"Calling `env.close()` on the closed environment should be allowed, but it raised an exception: {e}"
)
env.close()
try:
env.close()
except Exception as e:
warnings.warn(f"Calling `env.close()` on the closed environment should be allowed, but it raised an exception: {e}")