Ejemplo n.º 1
0
def test_coefficient_iter():
    c = Coefficient(ar(6))
    i = 0
    for C in c:
        assert len(C) == 1
        i += 1
    assert i == 6
    for i, C in enumerate(c.iter(True)):
        assert C == c.c[i]
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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])
Ejemplo n.º 4
0
def test_coefficient_copy():
    c = Coefficient(ar(6), geom.graphene(), k='HELLO', test='test')
    cc = c.copy()
    assert cc.info['k'] == 'HELLO'
    assert cc.info['test'] == 'test'
Ejemplo n.º 5
0
def test_coefficient_creation2():
    c = Coefficient(ar(6), geom.graphene(), k='HELLO')
    assert np.allclose(c.parent.xyz, geom.graphene().xyz)
    assert c.info['k'] == 'HELLO'