Skip to content

Commit

Permalink
[BugFix] Graceful attribute error exit in TensorDictParams (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens authored Nov 23, 2023
1 parent 1a7f43a commit 42bf143
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tensordict/nn/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def to_h5(
...

def __hash__(self):
return hash((id(self), id(self._param_td)))
return hash((id(self), id(self.__dict__.get("_param_td", None))))

@_fallback
def __eq__(self, other: object) -> TensorDictBase:
Expand All @@ -541,7 +541,7 @@ def __ne__(self, other: object) -> TensorDictBase:

def __getattr__(self, item: str) -> Any:
try:
return getattr(self._param_td, item)
return getattr(self.__dict__["_param_td"], item)
except AttributeError:
return super().__getattr__(item)

Expand Down

0 comments on commit 42bf143

Please sign in to comment.