def test_24(): subjects = RottenOptions() subjects.add( 'qcdb', RottenOption(keyword='scf_e_conv', default=5, validator=parsers.parse_convergence)) @register_opts(subjects) def energy(count=1, **kwargs): if count > 3: assert subjects.scroll['QCDB']['SCF_E_CONV'].value == 1.e-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_opts(subjects) def proc(count, **kwargs): energy(count) assert subjects.scroll['QCDB']['SCF_E_CONV'].value == 1.e-5 energy() assert subjects.scroll['QCDB']['SCF_E_CONV'].value == 1.e-5
def test_20(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(keyword='memory', default='700 mb', validator=parsers.parse_memory)) subjects.add('qcdb', RottenOption(keyword='e_convergence', default=7, validator=parsers.parse_convergence)) subjects.add('dftd3', RottenOption(keyword='Opt1', default=4, validator=lambda x: x)) subjects.add('dftd3', RottenOption(keyword='Opt1', default='cat', validator=lambda x: x)) print(subjects)
def test_22a(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(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
def test_21a(): subjects = RottenOptions() with pytest.raises(qcdb.ValidationError): subjects.add( 'random', RottenOption(keyword='memory', default='700 mb', validator=parsers.parse_memory))
def test_22c(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(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
def test_22b(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(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.OptionReconciliationError): assert subjects.scroll['QCDB']['MEMORY'].value == 8000000000
def test_22e(): subjects = RottenOptions() subjects.add( 'qcdb', RottenOption(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
def test_23d(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(keyword='scf_e_conv', default=5, validator=parsers.parse_convergence)) subjects.require('qcdb', 'scf_e_conv', 7, 1234) subjects.require('qcdb', 'e_conv', 1.e-6, 1234) assert subjects.scroll['QCDB']['SCF_E_CONV'].value == 1.e-7
def test_22d(): subjects = RottenOptions() subjects.add('qcdb', RottenOption(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
def test_21b(): subjects = RottenOptions() with pytest.raises(qcdb.ValidationError): subjects.require('qcdb', 'mmry', '4 gb', 1234)