def test_cstate_sub1(): state = StateC(ar(10, 10), ar(10)) assert len(state) == 10 norm = state.norm() norm2 = state.norm2() for i in range(len(state)): assert len(state.sub(i)) == 1 assert state.sub(i).norm()[0] == norm[i] assert state[i].norm()[0] == norm[i] assert state[i].norm2()[0] == norm2[i] assert state[i].c[0] == state.c[i] for i, sub in enumerate(state): assert len(sub) == 1 assert sub.norm()[0] == norm[i]
def test_cstate_sub(): state = StateC(ar(10, 10), ar(10)) assert len(state) == 10 norm = state.norm() norm2 = state.norm2() for i in range(len(state)): assert len(state.sub(i)) == 1 assert state.sub(i).norm()[0] == norm[i] assert state[i].norm()[0] == norm[i] assert state[i].norm2()[0] == norm2[i] assert state[i].c[0] == state.c[i] for i, sub in enumerate(state): assert len(sub) == 1 assert sub.norm()[0] == norm[i] sub = state.sub(np.array([False, True, False, True])) state.sub([1, 3], inplace=True) assert np.allclose(sub.c, state.c) assert np.allclose(sub.state, state.state)
def test_cstate_norm1(): state = StateC(ar(10, 10), ar(10)).normalize() assert len(state) == 10 assert np.allclose(state.norm(), 1) assert np.allclose(state.norm2(), 1)