Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions test/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ def test_multi_purpose_env(self, serial):
env = SerialEnv(2, ContinuousActionVecMockEnv)
else:
env = ContinuousActionVecMockEnv()
rollout = env.rollout(10)
env.rollout(10)
assert env._step_mdp.validate(None)
c = SyncDataCollector(
env, env.rand_action, frames_per_batch=10, total_frames=20
Expand All @@ -1736,7 +1736,18 @@ def test_multi_purpose_env(self, serial):
pass
assert ("collector", "traj_ids") in data.keys(True)
assert env._step_mdp.validate(None)
rollout = env.rollout(10)
env.rollout(10)

# An exception will be raised when the collector sees extra keys
if serial:
env = SerialEnv(2, ContinuousActionVecMockEnv)
else:
env = ContinuousActionVecMockEnv()
c = SyncDataCollector(
env, env.rand_action, frames_per_batch=10, total_frames=20
)
for data in c: # noqa: B007
pass


@pytest.mark.parametrize("device", get_default_devices())
Expand Down
2 changes: 1 addition & 1 deletion torchrl/envs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def validate(self, tensordict):
)
actual = set(tensordict.keys(True, True))
expected = set(expected)
self.validated = expected.union(actual) == expected
self.validated = expected.intersection(actual) == expected
if not self.validated:
warnings.warn(
"The expected key set and actual key set differ. "
Expand Down