Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit e5bf7e2

Browse files
authored
Fix symmetric svd decomp (#944)
* modify decompositions.svd to allow truncating all singular values * modify decompositions.svd to allow truncating all singular values * updated test_max_truncation_error * remove unusedvariable
1 parent d87ee43 commit e5bf7e2

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

tensornetwork/backends/symmetric/decompositions.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ def svd(
8484
#sort singular values
8585
inds = np.argsort(extended_flat_singvals, kind='stable')
8686
discarded_inds = np.zeros(0, dtype=SIZE_T)
87-
if inds.shape[0] > 0:
88-
maxind = inds[-1]
89-
else:
90-
maxind = 0
9187
if max_truncation_error is not None:
9288
if relative and (len(singvals) > 0):
9389
max_truncation_error = max_truncation_error * np.max(
@@ -114,9 +110,7 @@ def svd(
114110

115111
if len(inds) == 0:
116112
#special case of truncation to 0 dimension;
117-
warnings.warn("svd_decomposition truncated to 0 dimensions. "
118-
"Adjusting to `max_singular_values = 1`")
119-
inds = np.asarray([maxind])
113+
warnings.warn("svd_decomposition truncated to 0 dimensions.")
120114

121115
if extended_singvals.shape[1] > 0:
122116
#pylint: disable=no-member

tensornetwork/backends/symmetric/decompositions_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ def test_max_singular_values(dtype, R, R1, num_charges):
8787

8888
@pytest.mark.parametrize("dtype", np_dtypes)
8989
@pytest.mark.parametrize("num_charges", [1, 2, 3])
90-
def test_max_truncation_error(dtype, num_charges):
91-
np.random.seed(10)
90+
@pytest.mark.parametrize("seed", np.arange(20))
91+
def test_max_truncation_error(dtype, num_charges, seed):
92+
np.random.seed(seed)
9293
R = 2
9394
D = 30
9495
charges = [

0 commit comments

Comments
 (0)