Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions grassmann_tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,11 @@ def __iadd__(self, other: typing.Any) -> GrassmannTensor:
if isinstance(other, GrassmannTensor):
self._validate_edge_compatibility(other)
self._tensor += other._tensor
else:
return self
try:
self._tensor += other
except TypeError:
return NotImplemented
if isinstance(self._tensor, torch.Tensor):
return self
return NotImplemented
Expand Down Expand Up @@ -431,8 +434,11 @@ def __isub__(self, other: typing.Any) -> GrassmannTensor:
if isinstance(other, GrassmannTensor):
self._validate_edge_compatibility(other)
self._tensor -= other._tensor
else:
return self
try:
self._tensor -= other
except TypeError:
return NotImplemented
if isinstance(self._tensor, torch.Tensor):
return self
return NotImplemented
Expand Down Expand Up @@ -471,8 +477,11 @@ def __imul__(self, other: typing.Any) -> GrassmannTensor:
if isinstance(other, GrassmannTensor):
self._validate_edge_compatibility(other)
self._tensor *= other._tensor
else:
return self
try:
self._tensor *= other
except TypeError:
return NotImplemented
if isinstance(self._tensor, torch.Tensor):
return self
return NotImplemented
Expand Down Expand Up @@ -511,8 +520,11 @@ def __itruediv__(self, other: typing.Any) -> GrassmannTensor:
if isinstance(other, GrassmannTensor):
self._validate_edge_compatibility(other)
self._tensor /= other._tensor
else:
return self
try:
self._tensor /= other
except TypeError:
return NotImplemented
if isinstance(self._tensor, torch.Tensor):
return self
return NotImplemented
Expand Down