Example #1
0
def test_20():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))
    subjects.add("qcdb", Keyword(keyword="e_convergence", default=7, validator=parsers.parse_convergence))
    subjects.add("dftd3", Keyword(keyword="Opt1", default=4, validator=lambda x: x))
    subjects.add("dftd3", Keyword(keyword="Opt1", default="cat", validator=lambda x: x))

    print(subjects)
Example #2
0
def test_3():
    subject = Keyword(keyword="opt1", glossary="does stuff", validator=validator, default=6)
    # subject.value = 10
    subject.require(10)

    assert subject.value == 10
    # assert subject.has_changed is True
    assert subject.is_default() is False
Example #3
0
def test_6_conv():
    subject = Keyword(keyword="opt1", glossary="does stuff", validator=parsers.parse_convergence, default=6)

    # subject.value = 1
    subject.require(1)
    assert subject.value == 1.0e-1
    # assert subject.has_changed is True
    assert subject.is_default() is False
Example #4
0
def test_23d():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="scf_e_conv", default=5, validator=parsers.parse_convergence))
    subjects.require("qcdb", "scf_e_conv", 7, 1234)
    subjects.require("qcdb", "e_conv", 1.0e-6, 1234)

    assert subjects.scroll["QCDB"]["SCF_E_CONV"].value == 1.0e-7
Example #5
0
def test_22d():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))
    subjects.suggest("qcdb", "memory", 4000000000, 12342345)

    assert subjects.scroll["QCDB"]["MEMORY"].value == 4000000000
    assert subjects.scroll["QCDB"]["MEMORY"].is_default() is False
Example #6
0
def test_22a():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))
    subjects.require("qcdb", "memory", 9000000000, 22342345)
    subjects.suggest("qcdb", "memory", 4000000000, 12342345)
    subjects.require("qcdb", "memory", "9 gb", "00000000")

    assert subjects.scroll["QCDB"]["MEMORY"].value == 9000000000
Example #7
0
def test_22b():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))
    subjects.require("qcdb", "memory", 9000000000, 22342345)
    subjects.suggest("qcdb", "memory", 4000000000, 12342345)
    subjects.require("qcdb", "memory", "8 gb", "00000000")

    with pytest.raises(qcdb.KeywordReconciliationError):
        assert subjects.scroll["QCDB"]["MEMORY"].value == 8000000000
Example #8
0
def test_9_mem():
    subject = Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory)

    assert subject.value == 700000000

    subject.require(800000000)
    assert subject.value == 800000000

    subject.require(".6 Gb")
    assert subject.value == 600000000

    with pytest.raises(qcdb.KeywordValidationError):
        subject.require("8 dimms")
Example #9
0
def test_22c():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))
    subjects.require("qcdb", "memory", 9000000000, 22342345)
    subjects.suggest("qcdb", "memory", 4000000000, 12342345)
    subjects.require("qcdb", "memory", "8 gb", 555)  # no user signal so trumps 2234

    assert subjects.scroll["QCDB"]["MEMORY"].value == 8000000000
    assert subjects.scroll["QCDB"]["MEMORY"].is_default() is False

    import json

    s = json.dumps(subjects, sort_keys=True, indent=2, default=lambda x: x.__dict__)
    print(s)  # all but validator
Example #10
0
def test_1():
    subject = Keyword(keyword="opt1", glossary="does stuff", validator=validator, default=6)
    assert subject.value == 6
    # assert subject.has_changed is False
    assert subject.is_default() is True
    assert subject.keyword == "OPT1"

    # subject.value = 6
    subject.require(6)
    # assert subject.has_changed is True
    assert subject.is_default() is True
Example #11
0
def test_24():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="scf_e_conv", default=5, validator=parsers.parse_convergence))

    @register_kwds(subjects)
    def energy(count=1, **kwargs):
        if count > 3:
            assert subjects.scroll["QCDB"]["SCF_E_CONV"].value == 1.0e-4
            return
        else:
            count += 1
            # subjects.require('qcdb', 'scf_c_conv', count, accession=kwargs['accession'])
            subjects.require("qcdb", "scf_e_conv", count, accession=kwargs["accession"])
            proc(count)

    @register_kwds(subjects)
    def proc(count, **kwargs):
        energy(count)

    assert subjects.scroll["QCDB"]["SCF_E_CONV"].value == 1.0e-5
    energy()
    assert subjects.scroll["QCDB"]["SCF_E_CONV"].value == 1.0e-5
Example #12
0
def test_8_conv():
    subject = Keyword(keyword="opt1", glossary="does stuff", validator=parsers.parse_convergence, default=6)

    with pytest.raises(qcdb.KeywordValidationError):
        # subject.value = -1.0
        subject.require(-1.0)
Example #13
0
def test_2():
    with pytest.raises(qcdb.KeywordValidationError):
        subject = Keyword(keyword="opt2", glossary="does stuff", validator=validator, default=4)
Example #14
0
def alias_setup():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="freeze__core", default=0, validator=parsers.nonnegative_integer))
    subjects.add_alias("qcdb", AliasKeyword(alias="freeze", target="freeze__core"))

    return subjects
Example #15
0
def test_22e():
    subjects = Keywords()
    subjects.add("qcdb", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))

    assert subjects.scroll["QCDB"]["MEMORY"].value == 700000000
    assert subjects.scroll["QCDB"]["MEMORY"].is_default() is True
Example #16
0
def test_21a():
    subjects = Keywords()

    with pytest.raises(qcdb.ValidationError):
        subjects.add("random", Keyword(keyword="memory", default="700 mb", validator=parsers.parse_memory))