Skip to content

Commit

Permalink
Tensor flip call backend flip
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Feb 11, 2025
1 parent b0194e3 commit 422a89c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions quimb/tensor/tensor_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,10 +2960,8 @@ def flip(self, ind, inplace=False):
raise ValueError(f"Can't find index {ind} on this tensor.")

t = self if inplace else self.copy()
flipper = tuple(
slice(None, None, -1) if i == ind else slice(None) for i in t.inds
)
t.modify(apply=lambda x: x[flipper])
ax = t.inds.index(ind)
t.modify(apply=lambda x: do("flip", x, ax))
return t

flip_ = functools.partialmethod(flip, inplace=True)
Expand Down

0 comments on commit 422a89c

Please sign in to comment.