def test_coefficient_creation1(): c = Coefficient(ar(6)) str(c) assert len(c) == 6 assert c.shape == (6, ) assert c.dtype == np.float64 assert c.dkind == 'f' assert len(c.sub(1)) == 1 assert np.allclose(c.sub(1).c, 1) assert len(c.sub([1, 4])) == 2 assert np.allclose(c.sub([1, 4]).c, [1, 4]) assert np.allclose(c[1, 4].c, [1, 4])
def test_coefficient_sub(): state = ar(10) state = Coefficient(state) assert len(state) == 10 for i in range(len(state)): assert len(state.sub(i)) == 1 for i, sub in enumerate(state): assert len(sub) == 1 assert np.allclose( state.sub(np.array([False, True, False, True])).c, state.sub([1, 3]).c) sub = state.sub(np.array([False, True, False, True])) state.sub([1, 3], inplace=True) assert np.allclose(sub.c, state.c)