Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
vmoens committed Jan 9, 2025
2 parents 7a61c12 + 47a4175 commit 72e473b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tensordict/tensorclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,10 +2251,15 @@ def _batch_size(self) -> torch.Size:
"""
return self._tensordict.batch_size


def _batch_dims(self) -> torch.Size:
return self._tensordict.batch_dims


def _requires_grad(self) -> torch.Size:
return self._tensordict.requires_grad


def _is_locked(self) -> torch.Size:
return self._tensordict.is_locked

Expand Down
10 changes: 8 additions & 2 deletions test/test_tensorclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def _get_methods_from_class(cls):
methods = set()
for name in dir(cls):
attr = getattr(cls, name)
if inspect.isfunction(attr) or inspect.ismethod(attr) or isinstance(attr, property):
if (
inspect.isfunction(attr)
or inspect.ismethod(attr)
or isinstance(attr, property)
):
methods.add(name)

return methods
Expand Down Expand Up @@ -138,7 +142,9 @@ class X:

tensorclass_methods = _get_methods_from_class(X)

missing_methods = tensorclass_abstract_methods - tensorclass_methods - {"data", "grad"}
missing_methods = (
tensorclass_abstract_methods - tensorclass_methods - {"data", "grad"}
)
missing_methods = [
method for method in missing_methods if (not method.startswith("_"))
]
Expand Down

0 comments on commit 72e473b

Please sign in to comment.