-
-
Notifications
You must be signed in to change notification settings - Fork 953
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added list envs function (pretty print envs) (#124)
Co-authored-by: Mark Towers <[email protected]>
- Loading branch information
1 parent
55c02ed
commit 4d55f7c
Showing
4 changed files
with
251 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
import gymnasium as gym | ||
|
||
# To ignore the trailing whitespaces, will need flake to ignore this file. | ||
# flake8: noqa | ||
|
||
|
||
def test_pprint_custom_registry(): | ||
"""Testing a registry different from default.""" | ||
a = { | ||
"CartPole-v0": gym.envs.registry["CartPole-v0"], | ||
"CartPole-v1": gym.envs.registry["CartPole-v1"], | ||
} | ||
out = gym.pprint_registry(a) | ||
|
||
correct_out = """===== classic_control ===== | ||
CartPole-v0 | ||
CartPole-v1 | ||
""" | ||
|
||
assert out == correct_out | ||
|
||
|
||
def test_pprint_registry(): | ||
"""Testing the default registry, with no changes.""" | ||
out = gym.pprint_registry() | ||
|
||
correct_out = """===== classic_control ===== | ||
Acrobot-v1 | ||
CartPole-v0 | ||
CartPole-v1 | ||
MountainCar-v0 | ||
MountainCarContinuous-v0 | ||
Pendulum-v1 | ||
===== box2d ===== | ||
BipedalWalker-v3 | ||
BipedalWalkerHardcore-v3 | ||
CarRacing-v2 | ||
LunarLander-v2 | ||
LunarLanderContinuous-v2 | ||
===== toy_text ===== | ||
Blackjack-v1 | ||
CliffWalking-v0 | ||
FrozenLake-v1 | ||
FrozenLake8x8-v1 | ||
Taxi-v3 | ||
===== mujoco ===== | ||
Ant-v2 Ant-v3 Ant-v4 | ||
HalfCheetah-v2 HalfCheetah-v3 HalfCheetah-v4 | ||
Hopper-v2 Hopper-v3 Hopper-v4 | ||
Humanoid-v2 Humanoid-v3 Humanoid-v4 | ||
HumanoidStandup-v2 HumanoidStandup-v4 InvertedDoublePendulum-v2 | ||
InvertedDoublePendulum-v4 InvertedPendulum-v2 InvertedPendulum-v4 | ||
Pusher-v2 Pusher-v4 Reacher-v2 | ||
Reacher-v4 Swimmer-v2 Swimmer-v3 | ||
Swimmer-v4 Walker2d-v2 Walker2d-v3 | ||
Walker2d-v4 | ||
===== external ===== | ||
GymV26Environment-v0 | ||
===== utils_envs ===== | ||
RegisterDuringMakeEnv-v0 | ||
test.ArgumentEnv-v0 | ||
test.OrderlessArgumentEnv-v0 | ||
===== test ===== | ||
test/NoHuman-v0 | ||
test/NoHumanNoRGB-v0 | ||
test/NoHumanOldAPI-v0 | ||
""" | ||
assert out == correct_out | ||
|
||
|
||
def test_pprint_registry_exclude_namespaces(): | ||
"""Testing the default registry, with no changes.""" | ||
out = gym.pprint_registry( | ||
max_rows=20, | ||
exclude_namespaces=["classic_control"], | ||
) | ||
|
||
correct_out = """===== box2d ===== | ||
BipedalWalker-v3 | ||
BipedalWalkerHardcore-v3 | ||
CarRacing-v2 | ||
LunarLander-v2 | ||
LunarLanderContinuous-v2 | ||
===== toy_text ===== | ||
Blackjack-v1 | ||
CliffWalking-v0 | ||
FrozenLake-v1 | ||
FrozenLake8x8-v1 | ||
Taxi-v3 | ||
===== mujoco ===== | ||
Ant-v2 Ant-v3 | ||
Ant-v4 HalfCheetah-v2 | ||
HalfCheetah-v3 HalfCheetah-v4 | ||
Hopper-v2 Hopper-v3 | ||
Hopper-v4 Humanoid-v2 | ||
Humanoid-v3 Humanoid-v4 | ||
HumanoidStandup-v2 HumanoidStandup-v4 | ||
InvertedDoublePendulum-v2 InvertedDoublePendulum-v4 | ||
InvertedPendulum-v2 InvertedPendulum-v4 | ||
Pusher-v2 Pusher-v4 | ||
Reacher-v2 Reacher-v4 | ||
Swimmer-v2 Swimmer-v3 | ||
Swimmer-v4 Walker2d-v2 | ||
Walker2d-v3 Walker2d-v4 | ||
===== external ===== | ||
GymV26Environment-v0 | ||
===== utils_envs ===== | ||
RegisterDuringMakeEnv-v0 | ||
test.ArgumentEnv-v0 | ||
test.OrderlessArgumentEnv-v0 | ||
===== test ===== | ||
test/NoHuman-v0 | ||
test/NoHumanNoRGB-v0 | ||
test/NoHumanOldAPI-v0 | ||
""" | ||
assert out == correct_out | ||
|
||
|
||
def test_pprint_registry_no_entry_point(): | ||
"""Test registry if there is environment with no entry point.""" | ||
|
||
gym.register("NoNamespaceEnv", "no-entry-point") | ||
out = gym.pprint_registry() | ||
|
||
correct_out = """===== classic_control ===== | ||
Acrobot-v1 | ||
CartPole-v0 | ||
CartPole-v1 | ||
MountainCar-v0 | ||
MountainCarContinuous-v0 | ||
Pendulum-v1 | ||
===== box2d ===== | ||
BipedalWalker-v3 | ||
BipedalWalkerHardcore-v3 | ||
CarRacing-v2 | ||
LunarLander-v2 | ||
LunarLanderContinuous-v2 | ||
===== toy_text ===== | ||
Blackjack-v1 | ||
CliffWalking-v0 | ||
FrozenLake-v1 | ||
FrozenLake8x8-v1 | ||
Taxi-v3 | ||
===== mujoco ===== | ||
Ant-v2 Ant-v3 Ant-v4 | ||
HalfCheetah-v2 HalfCheetah-v3 HalfCheetah-v4 | ||
Hopper-v2 Hopper-v3 Hopper-v4 | ||
Humanoid-v2 Humanoid-v3 Humanoid-v4 | ||
HumanoidStandup-v2 HumanoidStandup-v4 InvertedDoublePendulum-v2 | ||
InvertedDoublePendulum-v4 InvertedPendulum-v2 InvertedPendulum-v4 | ||
Pusher-v2 Pusher-v4 Reacher-v2 | ||
Reacher-v4 Swimmer-v2 Swimmer-v3 | ||
Swimmer-v4 Walker2d-v2 Walker2d-v3 | ||
Walker2d-v4 | ||
===== external ===== | ||
GymV26Environment-v0 | ||
===== utils_envs ===== | ||
RegisterDuringMakeEnv-v0 | ||
test.ArgumentEnv-v0 | ||
test.OrderlessArgumentEnv-v0 | ||
===== test ===== | ||
test/NoHuman-v0 | ||
test/NoHumanNoRGB-v0 | ||
test/NoHumanOldAPI-v0 | ||
===== NoNamespaceEnv ===== | ||
NoNamespaceEnv | ||
""" | ||
assert out == correct_out | ||
|
||
del gym.envs.registry["NoNamespaceEnv"] |