Skip to content

Commit

Permalink
[Minor] Fix tensorclass prints
Browse files Browse the repository at this point in the history
ghstack-source-id: 46d70d783e59f86f1720cd6bede12049de57d095
Pull Request resolved: #1218
  • Loading branch information
vmoens committed Feb 13, 2025
1 parent 0fccd26 commit e3d7ec4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tensordict/tensorclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,9 +1868,16 @@ def _repr(self) -> str:
",\n".join(non_tensor_fields),
4 * " ",
)
string = ",\n".join(field_str + [non_tensor_field_str, *medatada_fields])
else:
if field_str:
string = ",\n".join(field_str + [non_tensor_field_str, *medatada_fields])
else:
string = ",\n".join([non_tensor_field_str, *medatada_fields])
elif field_str:
string = ",\n".join(field_str + medatada_fields)
elif len(medatada_fields) > 0:
string = ",\n".join(medatada_fields)
else:
string = ""
return f"{type(self).__name__}({string})"


Expand Down

0 comments on commit e3d7ec4

Please sign in to comment.