Skip to content

Commit

Permalink
fixes for arbgeom tebd ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Sep 20, 2024
1 parent de46163 commit 89f13f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions quimb/tensor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tensor and tensor network functionality.
"""
"""Tensor and tensor network functionality."""

from .circuit import (
Circuit,
Expand Down
2 changes: 1 addition & 1 deletion quimb/tensor/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ def sample_bitstring_from_prob_ndarray(p):
>>> sample_bitstring_from_prob_ndarray(p)
'01011'
"""
b = np.random.choice(np.arange(p.size), p=p.flat)
b = np.random.choice(p.size, p=p.flat)
return f"{b:0>{p.ndim}b}"


Expand Down
12 changes: 8 additions & 4 deletions quimb/tensor/tensor_arbgeom_tebd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import itertools
import collections

from autoray import do, to_numpy, dag
from autoray import do, to_numpy

from ..core import eye, kron, qarray
from ..utils import ensure_dict
Expand Down Expand Up @@ -54,11 +54,16 @@ def edge_coloring(
coloring.setdefault(color, []).append(edge)

if group:
return tuple(tuple(coloring[color]) for color in sorted(coloring))
return tuple(
tuple(tuple(tuple(sorted(edge)) for edge in coloring[color]))
for color in sorted(coloring)
)
else:
# flatten sorted groups
return tuple(
edge for color in sorted(coloring) for edge in coloring[color]
tuple(sorted(edge))
for color in sorted(coloring)
for edge in coloring[color]
)


Expand Down Expand Up @@ -657,7 +662,6 @@ def _check_energy(self):
if self.keep_best and en < self.best["energy"]:
self.best["energy"] = en
self.best["state"] = self.state
self.best["gauges"] = self.gauges.copy()
self.best["it"] = self._n

return self.energies[-1]
Expand Down

0 comments on commit 89f13f2

Please sign in to comment.