|
|
|
|
|
|
assert specs.discrete_branches == () |
|
|
|
assert specs.discrete_size == 0 |
|
|
|
assert specs.continuous_size == 3 |
|
|
|
assert specs.create_empty(5).shape == (5, 3) |
|
|
|
assert specs.create_empty(5).dtype == np.float32 |
|
|
|
assert specs.empty_action(5).shape == (5, 3) |
|
|
|
assert specs.empty_action(5).dtype == np.float32 |
|
|
|
assert specs.create_empty(5).shape == (5, 1) |
|
|
|
assert specs.create_empty(5).dtype == np.int32 |
|
|
|
assert specs.empty_action(5).shape == (5, 1) |
|
|
|
assert specs.empty_action(5).dtype == np.int32 |
|
|
|
|
|
|
|
|
|
|
|
def test_action_generator(): |
|
|
|
|
|
|
zero_action = specs.create_empty(4) |
|
|
|
zero_action = specs.empty_action(4) |
|
|
|
assert np.array_equal(zero_action, np.zeros((4, action_len), dtype=np.float32)) |
|
|
|
random_action = specs.random_action(4) |
|
|
|
assert random_action.dtype == np.float32 |
|
|
|
|
|
|
# Discrete |
|
|
|
action_shape = (10, 20, 30) |
|
|
|
specs = ActionSpec.create_discrete(action_shape) |
|
|
|
zero_action = specs.create_empty(4) |
|
|
|
zero_action = specs.empty_action(4) |
|
|
|
assert np.array_equal(zero_action, np.zeros((4, len(action_shape)), dtype=np.int32)) |
|
|
|
|
|
|
|
random_action = specs.random_action(4) |
|
|
|