Esempio n. 1
0
 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
Esempio n. 2
0
 def test_bsz1_start_right(self):
     tn = MPS_rand_state(6, bond_dim=7)
     env = MovingEnvironment(tn, begin='right', bsz=1)
     assert env.pos == 5
     assert len(env().tensors) == 3
     env.move_left()
     assert env.pos == 4
     assert len(env().tensors) == 3
     env.move_left()
     assert env.pos == 3
     assert len(env().tensors) == 3
     env.move_to(0)
     assert env.pos == 0
     assert len(env().tensors) == 3
Esempio n. 3
0
 def test_bsz1_start_left(self):
     tn = MPS_rand_state(6, bond_dim=7)
     env = MovingEnvironment(tn, n=6, start='left', bsz=1)
     assert env.pos == 0
     assert len(env().tensors) == 2
     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) == 2
Esempio n. 4
0
 def test_bsz2_start_right(self):
     tn = MPS_rand_state(6, bond_dim=7)
     env = MovingEnvironment(tn, n=6, start='right', bsz=2)
     assert env.pos == 4
     assert len(env().tensors) == 3
     env.move_left()
     assert env.pos == 3
     assert len(env().tensors) == 4
     env.move_left()
     assert env.pos == 2
     assert len(env().tensors) == 4
     with pytest.raises(ValueError):
         env.move_to(-1)
     env.move_to(0)
     assert env.pos == 0
     assert len(env().tensors) == 3