def test_partial_trace_compress(self, method, cyclic, sysa, sysb): k = MPS_rand_state(60, 8, cyclic=cyclic) kws = dict(sysa=sysa, sysb=sysb, eps=1e-4, method=method) if len(sysa) + len(sysb) == 60: with pytest.raises(ValueError): k.partial_trace_compress(**kws) return rhoc_ab = k.partial_trace_compress(**kws) assert set(rhoc_ab.outer_inds()) == {'kA', 'kB', 'bA', 'bB'} inds = ['kA', 'kB'], ['bA', 'bB'] x = rhoc_ab.trace(*inds) assert_allclose(1.0, x, rtol=1e-3)
def test_known_bad_case(self, cyclic): k = MPS_rand_state(5, 10, cyclic=cyclic) rhoc_ab = k.partial_trace_compress(sysa=range(2), sysb=range(2, 4)) inds = ['kA', 'kB'], ['bA', 'bB'] x = rhoc_ab.trace(*inds) assert_allclose(1.0, x, rtol=1e-3)