[rllib] Fix linting (#24335)

#24262 broke linting. This fixes this.
This commit is contained in:
Kai Fricke 2022-04-29 15:21:11 +01:00 committed by GitHub
parent 46cd7f1830
commit 242706922b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 27 deletions

View file

@ -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), "a": gym.spaces.Discrete(2),
"b": gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32), "b": gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32),
"c": gym.spaces.Tuple( "c": gym.spaces.Tuple(
( (
gym.spaces.Discrete(2), gym.spaces.Discrete(2),
gym.spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32), 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"])