Skip to content

Commit

Permalink
Fixed test_env_checker.test_no_error_warnings test, which previously …
Browse files Browse the repository at this point in the history
…failed due to the velocity observation limits of CartPole being infinite
  • Loading branch information
TimSchneider42 committed Jul 2, 2024
1 parent d3df691 commit 251cf7b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/utils/test_env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
from tests.testing_env import GenericTestEnv


CHECK_ENV_IGNORE_WARNINGS = [
f"\x1b[33mWARN: {message}\x1b[0m"
for message in [
"A Box observation space minimum value is -infinity. This is probably too low.",
"A Box observation space maximum value is infinity. This is probably too high.",
"For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.",
]
]


@pytest.mark.parametrize(
"env",
[
Expand Down Expand Up @@ -51,6 +61,11 @@ def test_no_error_warnings(env):
"""A full version of this test with all gymnasium envs is run in tests/envs/test_envs.py."""
with warnings.catch_warnings(record=True) as caught_warnings:
check_env(env)
caught_warnings = [
warning
for warning in caught_warnings
if str(warning.message) not in CHECK_ENV_IGNORE_WARNINGS
]

assert len(caught_warnings) == 0, [warning.message for warning in caught_warnings]

Expand Down

0 comments on commit 251cf7b

Please sign in to comment.