Skip to content

Commit

Permalink
avoid import torch for type check in MontyEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Oct 20, 2024
1 parent 1270c7b commit a7752ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/monty/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ def default(self, o) -> dict:
if isinstance(o, Path):
return {"@module": "pathlib", "@class": "Path", "string": str(o)}

if torch is not None and isinstance(o, torch.Tensor):
# Support for Pytorch Tensors.
# Support for Pytorch Tensors
if _check_type(o, "torch.Tensor"):
d: dict[str, Any] = {
"@module": "torch",
"@class": "Tensor",
Expand Down

0 comments on commit a7752ee

Please sign in to comment.