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
❯ : uv run tensorclass_get_default.py
Reading inline script metadata from `tensorclass_get_default.py`
Traceback (most recent call last):
File "[...]/tensorclass_get_default.py", line 18, in<module>
Data(td=TensorDict({})).get(("td", "missing"), default=None) File "/home/evgenii/.cache/uv/archive-v0/yCPXuVvMie1NN0uqK0b3L/lib/python3.12/site-packages/tensordict/tensorclass.py", line 1792, in _get return getattr(self, key[0]).get(key[1:]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/evgenii/.cache/uv/archive-v0/yCPXuVvMie1NN0uqK0b3L/lib/python3.12/site-packages/tensordict/base.py", line 5044, in get return self._get_tuple(key, default=default) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/evgenii/.cache/uv/archive-v0/yCPXuVvMie1NN0uqK0b3L/lib/python3.12/site-packages/tensordict/_td.py", line 2468, in _get_tuple first = self._get_str(key[0], default) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/evgenii/.cache/uv/archive-v0/yCPXuVvMie1NN0uqK0b3L/lib/python3.12/site-packages/tensordict/_td.py", line 2464, in _get_str return self._default_get(first_key, default) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/evgenii/.cache/uv/archive-v0/yCPXuVvMie1NN0uqK0b3L/lib/python3.12/site-packages/tensordict/base.py", line 4995, in _default_get raise KeyError(KeyError: 'key "missing" not found in TensorDict with keys []'
Expected behavior
The default kwarg is propagated as if on a nested TensorDict.
System info
0.6.2 2.2.2 3.12.0 (main, Oct 3 2023, 01:27:23) [Clang 17.0.1 ] linux 2.6.0+cu124
Reason and Possible fixes
tensordict.set_get_defaults_to_none(True) fixes this if we want the default to be None specifically.
Checklist
I have checked that there is no similar issue in the repo (required)
Describe the bug
When calling
.get()
on a@tensorclass
withTensorDict
attributes, thedefault
kwarg does not seem to be propagated properly.To Reproduce
Expected behavior
The
default
kwarg is propagated as if on a nestedTensorDict
.System info
Reason and Possible fixes
tensordict.set_get_defaults_to_none(True)
fixes this if we want the default to beNone
specifically.Checklist
The text was updated successfully, but these errors were encountered: