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
{{ message }}
Repository navigation
[BUG] NonTensorData.empty(names=...) ignores the names it is given #2501
NonTensorData.empty() and MetaData.empty() accept names, but the result never gets them: it keeps the old names, or has none when a batch_size is also given without names. TensorDict.empty(names=...) sets the names, so code that passes names to empty() on any tensor collection gets the wrong names back when the collection is a non-tensor entry.
Expected: ['n'] in every case, as TensorDict.empty(names=["n"]) gives.
Cause: NonTensorDataBase.empty (tensordict/tensorclass.py:5527-5536) sets names = None when a batch_size is given without names, and otherwise always replaces names with self._maybe_names(), so a names argument is never used.
Possible fix: use names when it is given, else None with a new batch_size, else self._maybe_names(). Only calls that pass names change, and those return the wrong names today. Found while working on #2467.
tensordict main (eba7879), torch 2.14.1, Python 3.12.12.
Activity