Skip to content

Commit

Permalink
TN distance: lossen test tol + add precision note
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Jan 31, 2024
1 parent 7a7c95d commit 4606f28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion quimb/tensor/tensor_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,10 @@ def tensor_network_distance(
= ( \langle A | A \rangle - 2 \mathrm{Re} \langle A | B \rangle|
+ \langle B | B \rangle ) ^{1/2}
which should have a matching external indices.
which should have matching outer indices. Note the default approach to
computing the norm is precision limited to about ``eps**0.5`` where ``eps``
is the precision of the data type, e.g. ``1e-8`` for float64. This is due
to the subtraction in the above expression.
Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tensor/test_tensor_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,10 @@ def test_subgraphs(_):
def test_expand_bond_dimension_zeros(self):
k = MPS_rand_state(10, 7)
k0 = k.copy()
k0.expand_bond_dimension(13)
k0.expand_bond_dimension_(13)
assert k0.max_bond() == 13
assert k0.ind_size("k0") == 2
assert k0.distance(k) == pytest.approx(0.0)
assert k0.distance(k) == pytest.approx(0.0, abs=1e-7)

def test_expand_bond_dimension_random(self):
tn = qtn.TN_rand_reg(6, 3, 2, dist="uniform")
Expand Down

0 comments on commit 4606f28

Please sign in to comment.