def test_bsz2_start_left(self): tn = MPS_rand_state(6, bond_dim=7) env = MovingEnvironment(tn, begin='left', bsz=2) assert len(env().tensors) == 4 env.move_right() assert len(env().tensors) == 4 env.move_right() assert len(env().tensors) == 4 with pytest.raises(ValueError): env.move_to(5) env.move_to(4) assert env.pos == 4 assert len(env().tensors) == 4
def test_bsz1_start_left(self): tn = MPS_rand_state(6, bond_dim=7) env = MovingEnvironment(tn, begin='left', bsz=1) assert env.pos == 0 assert len(env().tensors) == 3 env.move_right() assert env.pos == 1 assert len(env().tensors) == 3 env.move_right() assert env.pos == 2 assert len(env().tensors) == 3 env.move_to(5) assert env.pos == 5 assert len(env().tensors) == 3
def test_cyclic_moving_env_init_left(self, n, bsz, ssz): nenv = 2 p = MPS_rand_state(n, 4, cyclic=True) norm = p.H & p mes = MovingEnvironment(norm, begin='left', bsz=bsz, cyclic=True, ssz=ssz) assert len(mes.envs) == n // 2 + n % 2 assert mes.pos == 0 assert len(mes.envs[0].tensors) == 2 * bsz + nenv assert len(mes.envs[n // 2 - 1].tensors) == 2 * bsz + 1 assert n // 2 + n % 2 not in mes.envs assert n - 1 not in mes.envs for i in range(1, 2 * n): mes.move_right() assert mes.pos == i % n cur_env = mes() assert len(cur_env.tensors) == 2 * bsz + nenv assert (cur_env ^ all) == pytest.approx(1.0)