Skip to content

Commit 6b0d5b8

Browse files
author
Vincent Moens
committed
[BugFix] Use brackets to get non-tensor data in gym envs
ghstack-source-id: 3101141 Pull Request resolved: #2769 (cherry picked from commit 84f6b04)
1 parent 5f4c7da commit 6b0d5b8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torchrl/envs/gym_like.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def read_obs(
293293

294294
def _step(self, tensordict: TensorDictBase) -> TensorDictBase:
295295
if len(self.action_keys) == 1:
296-
action = tensordict.get(self.action_key)
296+
# Use brackets to get non-tensor data
297+
action = tensordict[self.action_key]
297298
else:
298299
action = tensordict.select(*self.action_keys).to_dict()
299300
if self._convert_actions_to_numpy:

0 commit comments

Comments
 (0)