def test_fuse(self): a = Tensor(np.random.rand(2, 3, 4, 5), 'abcd', tags={'blue'}) b = a.fuse({'bra': ['a', 'c'], 'ket': 'bd'}) assert set(b.shape) == {8, 15} assert set(b.inds) == {'bra', 'ket'} assert b.tags == {'blue'} b = a.fuse({'ket': 'bd', 'bra': 'ac'}) assert set(b.shape) == {15, 8} assert set(b.inds) == {'ket', 'bra'} assert b.tags == {'blue'}
def test_fuse_leftover(self): a = Tensor(np.random.rand(2, 3, 4, 5, 2, 2), 'abcdef', tags={'blue'}) b = a.fuse({'bra': 'ac', 'ket': 'bd'}) assert b.shape == (8, 15, 2, 2) assert b.inds == ('bra', 'ket', 'e', 'f') assert b.tags == {'blue'}