From e32accc1474906c3b3948695428bf34548d9de45 Mon Sep 17 00:00:00 2001 From: Johnnie Gray Date: Tue, 23 Jan 2024 23:53:54 -0800 Subject: [PATCH] qu. discord: increase maxiter --- quimb/calc.py | 4 ++++ tests/test_calc.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quimb/calc.py b/quimb/calc.py index 190ff49c..1979e62a 100644 --- a/quimb/calc.py +++ b/quimb/calc.py @@ -956,6 +956,7 @@ def quantum_discord( sysb=1, method="COBYLA", tol=1e-12, + maxiter=2**14, ): """Quantum Discord for two qubit density operator. @@ -996,6 +997,9 @@ def trial_qd(a): method=method, bounds=((0, pi), (0, 2 * pi)), tol=tol, + options=dict( + maxiter=maxiter, + ), ) if opt.success: return opt.fun diff --git a/tests/test_calc.py b/tests/test_calc.py index b75a46a4..4bd554d9 100644 --- a/tests/test_calc.py +++ b/tests/test_calc.py @@ -520,8 +520,10 @@ def test_auto_trace_out(self): qd = qu.quantum_discord(p, [2, 2, 2], 0, 2) assert 0 <= qd and qd <= 1 - def test_qu_discord_diagonal(self): - p = np.random.rand(4) + @pytest.mark.parametrize("seed", range(10)) + def test_qu_discord_diagonal(self, seed): + rng = np.random.RandomState(seed) + p = rng.random(size=4) p /= np.sum(p) rho = np.diag(p) assert qu.quantum_discord(rho) < 1e-10