예제 #1
0
def test_card_name_must_be_in_enum():
    from traitlets import TraitError
    from pytest import raises

    card = Card("ATOMIC_SPECIES")
    with raises(TraitError):
        card.name = "nothing"
예제 #2
0
def test_goaround_subtitled(subtitled_stream):
    from six import StringIO
    card, read_card = Card('K_POINTS'), Card('K_POINTS')
    card.read(subtitled_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == 'k_points'
    assert read_card.subtitle == 'tpiba'
    assert read_card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #3
0
def test_goaround(card_stream):
    from six import StringIO
    card, read_card = Card('ATOMIC_SPECIES'), Card('ATOMIC_SPECIES')
    card.read(card_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == 'atomic_species'
    assert read_card.subtitle is None
    assert read_card.value == 'Al 1 this.that'
예제 #4
0
def test_goaround_subtitled(subtitled_stream):
    from six import StringIO

    card, read_card = Card("K_POINTS"), Card("K_POINTS")
    card.read(subtitled_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == "k_points"
    assert read_card.subtitle == "tpiba"
    assert read_card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #5
0
def test_goaround(card_stream):
    from six import StringIO

    card, read_card = Card("ATOMIC_SPECIES"), Card("ATOMIC_SPECIES")
    card.read(card_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == "atomic_species"
    assert read_card.subtitle is None
    assert read_card.value == "Al 1 this.that"
예제 #6
0
def test_read_but_not_find(subtitled_stream, card_stream):
    from six import StringIO
    card, read_card = Card('ATOMIC_SPECIES'), Card('K_POINTS')
    read_card.read(subtitled_stream)
    card.read(card_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == 'k_points'
    assert read_card.subtitle == 'tpiba'
    assert read_card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #7
0
def test_read_but_not_find(subtitled_stream, card_stream):
    from six import StringIO

    card, read_card = Card("ATOMIC_SPECIES"), Card("K_POINTS")
    read_card.read(subtitled_stream)
    card.read(card_stream)
    read_card.read(StringIO(str(card)))
    assert read_card.name == "k_points"
    assert read_card.subtitle == "tpiba"
    assert read_card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #8
0
def test_free_cell(celldim, subtitle, expected_scale):
    from numpy import allclose, abs, array
    from pylada.espresso import Card, Namelist

    namelist = Namelist({'ibrav': 0})
    if celldim is not None:
        namelist.celldm = celldim

    card = Card('CELL_PARAMETERS',
                subtitle=subtitle,
                value="""
        1 2 3
        2 3 4
        4 4 6
    """)

    cell, scale = sh._read_free(namelist, card)
    assert allclose(cell,
                    array([[1, 2, 4], [2, 3, 4], [3, 4, 6]], dtype='float64'))
    assert abs(scale - expected_scale) < 1e-8
예제 #9
0
def test_read_subtitled_card(subtitled_stream):
    card = Card('K_POINTS')
    card.read(subtitled_stream)
    assert card.name == 'k_points'
    assert card.subtitle == 'tpiba'
    assert card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #10
0
def test_read_card(card_stream):
    card = Card('ATOMIC_SPECIES')
    card.read(card_stream)
    assert card.name == 'atomic_species'
    assert card.subtitle is None
    assert card.value == 'Al 1 this.that'
예제 #11
0
def test_create_card_with_value_and_subtitle():
    card = Card('ATOMIC_SPECIES', 'subtitle', '2')
    assert card.name == 'atomic_species'
    assert card.subtitle == '2'
    assert card.value == 'subtitle'
예제 #12
0
def test_create_card():
    card = Card('ATOMIC_SPECIES')
    assert card.name == 'atomic_species'
    assert card.subtitle is None
    assert card.value is None
예제 #13
0
def test_set_card_name():
    card = Card("ATOMIC_SPECIES")
    card.name = "k_poinTs"
    assert card.name == "k_points"
예제 #14
0
def test_card_name_must_be_in_enum():
    from traitlets import TraitError
    from pytest import raises
    card = Card('ATOMIC_SPECIES')
    with raises(TraitError):
        card.name = 'nothing'
예제 #15
0
def test_read_subtitled_card(subtitled_stream):
    card = Card("K_POINTS")
    card.read(subtitled_stream)
    assert card.name == "k_points"
    assert card.subtitle == "tpiba"
    assert card.value == "2\n0 0 0 0.8\n0.5 0.5 0.5 0.2"
예제 #16
0
def test_read_card(card_stream):
    card = Card("ATOMIC_SPECIES")
    card.read(card_stream)
    assert card.name == "atomic_species"
    assert card.subtitle is None
    assert card.value == "Al 1 this.that"
예제 #17
0
def test_allowed_card_name_dynamic_in_constructor():
    card = Card('NeWnaMe')
    assert card.name == 'newname'
예제 #18
0
def test_set_card_name():
    card = Card('ATOMIC_SPECIES')
    card.name = 'k_poinTs'
    assert card.name == 'k_points'