mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
parent
46cd7f1830
commit
242706922b
2 changed files with 33 additions and 27 deletions
|
@ -76,13 +76,13 @@ class TestUtils(unittest.TestCase):
|
||||||
# and integers are immutable by nature.
|
# and integers are immutable by nature.
|
||||||
|
|
||||||
# Test MultiDiscrete space.
|
# Test MultiDiscrete space.
|
||||||
space = gym.spaces.MultiDiscrete([3,3,3])
|
space = gym.spaces.MultiDiscrete([3, 3, 3])
|
||||||
action = space.sample()
|
action = space.sample()
|
||||||
action = make_action_immutable(action)
|
action = make_action_immutable(action)
|
||||||
self.assertFalse(action.flags["WRITEABLE"])
|
self.assertFalse(action.flags["WRITEABLE"])
|
||||||
|
|
||||||
# Test MultiBinary space.
|
# Test MultiBinary space.
|
||||||
space = gym.spaces.MultiBinary([2,2,2])
|
space = gym.spaces.MultiBinary([2, 2, 2])
|
||||||
action = space.sample()
|
action = space.sample()
|
||||||
action = make_action_immutable(action)
|
action = make_action_immutable(action)
|
||||||
self.assertFalse(action.flags["WRITEABLE"])
|
self.assertFalse(action.flags["WRITEABLE"])
|
||||||
|
@ -99,20 +99,26 @@ class TestUtils(unittest.TestCase):
|
||||||
self.assertFalse(action[1].flags["WRITEABLE"])
|
self.assertFalse(action[1].flags["WRITEABLE"])
|
||||||
|
|
||||||
# Test Dict space.
|
# Test Dict space.
|
||||||
space = gym.spaces.Dict({
|
space = gym.spaces.Dict(
|
||||||
"a": gym.spaces.Discrete(2),
|
{
|
||||||
"b": gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32),
|
"a": gym.spaces.Discrete(2),
|
||||||
"c": gym.spaces.Tuple(
|
"b": gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32),
|
||||||
(
|
"c": gym.spaces.Tuple(
|
||||||
gym.spaces.Discrete(2),
|
(
|
||||||
gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32),
|
gym.spaces.Discrete(2),
|
||||||
)
|
gym.spaces.Box(
|
||||||
)
|
low=-1.0, high=1.0, shape=(8,), dtype=np.float32
|
||||||
})
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
action = space.sample()
|
action = space.sample()
|
||||||
action = tree.traverse(make_action_immutable, action, top_down=False)
|
action = tree.traverse(make_action_immutable, action, top_down=False)
|
||||||
|
|
||||||
def fail_fun(obj):
|
def fail_fun(obj):
|
||||||
obj["a"] = 5
|
obj["a"] = 5
|
||||||
|
|
||||||
self.assertRaises(TypeError, fail_fun, action)
|
self.assertRaises(TypeError, fail_fun, action)
|
||||||
self.assertFalse(action["b"].flags["WRITEABLE"])
|
self.assertFalse(action["b"].flags["WRITEABLE"])
|
||||||
self.assertFalse(action["c"][1].flags["WRITEABLE"])
|
self.assertFalse(action["c"][1].flags["WRITEABLE"])
|
||||||
|
|
Loading…
Add table
Reference in a new issue