You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
will raise an exception because "a" somehow became a key of td.
Importantly, it causes error for
# TransformedEnvdef_step(self, tensordict: TensorDictBase) ->TensorDictBase:
tensordict=tensordict.clone(False)
next_preset=tensordict.get("next", None)
tensordict_in=self.transform.inv(tensordict)
next_tensordict=self.base_env._step(tensordict_in)
ifnext_presetisnotNone:
# tensordict could already have a "next" key# this could be done more efficiently by not excluding but just passing# the necessary keysnext_tensordict.update(
next_preset.exclude(*next_tensordict.keys(True, True))
)
self.base_env._complete_done(self.base_env.full_done_spec, next_tensordict)
# we want the input entries to remain unchangednext_tensordict=self.transform._step(tensordict, next_tensordict)
returnnext_tensordict
when next_preset is not None.
Reason and Possible fixes
It seems like a typo in _td.py.
def_exclude(self, ...):
...
ifkeys_to_excludeisnotNone:
forkey, cur_keysinkeys_to_exclude.items():
val=_tensordict.get(key, None)
ifvalisnotNone:
val=val._exclude(
*cur_keys, inplace=inplace, set_shared=set_shared
)
# missing indentifnotinplace:
_tensordict[key] =val# this would add the key to the result
Checklist
I have checked that there is no similar issue in the repo (required)
Describe the bug
tensordict.exclude
unexpectedly adds a key to exclude to the result if the key is a nested key.To Reproduce
Running
will raise an exception because "a" somehow became a key of
td
.Importantly, it causes error for
when
next_preset
is notNone
.Reason and Possible fixes
It seems like a typo in
_td.py
.Checklist
The text was updated successfully, but these errors were encountered: