mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-22 07:02:19 +00:00
Change import gymnasium to import gymnasium as gym (#20)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import gymnasium.spaces
|
||||
import gymnasium as gym
|
||||
from gymnasium.spaces import Box, Dict, Discrete, MultiBinary, Tuple
|
||||
from gymnasium.utils.env_checker import data_equivalence
|
||||
|
||||
@@ -79,7 +79,7 @@ def test_seeds(space, seed, expected_len):
|
||||
"space_fn",
|
||||
[
|
||||
lambda: Tuple(["abc"]),
|
||||
lambda: Tuple([gymnasium.spaces.Box(0, 1), "abc"]),
|
||||
lambda: Tuple([gym.spaces.Box(0, 1), "abc"]),
|
||||
lambda: Tuple("abc"),
|
||||
],
|
||||
)
|
||||
@@ -89,25 +89,19 @@ def test_bad_space_calls(space_fn):
|
||||
|
||||
|
||||
def test_contains_promotion():
|
||||
space = gymnasium.spaces.Tuple(
|
||||
(gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(-1, 0, (2,)))
|
||||
)
|
||||
space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(-1, 0, (2,))))
|
||||
|
||||
assert (
|
||||
np.array([0.0], dtype=np.float32),
|
||||
np.array([0.0, 0.0], dtype=np.float32),
|
||||
) in space
|
||||
|
||||
space = gymnasium.spaces.Tuple(
|
||||
(gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(-1, 0, (1,)))
|
||||
)
|
||||
space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(-1, 0, (1,))))
|
||||
assert np.array([[0.0], [0.0]], dtype=np.float32) in space
|
||||
|
||||
|
||||
def test_bad_seed():
|
||||
space = gymnasium.spaces.Tuple(
|
||||
(gymnasium.spaces.Box(0, 1), gymnasium.spaces.Box(0, 1))
|
||||
)
|
||||
space = gym.spaces.Tuple((gym.spaces.Box(0, 1), gym.spaces.Box(0, 1)))
|
||||
with pytest.raises(
|
||||
TypeError,
|
||||
match="Expected seed type: list, tuple, int or None, actual type: <class 'float'>",
|
||||
|
Reference in New Issue
Block a user