Skip to content

Commit

Permalink
Adding in coverage dependent database tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mazeau committed Mar 19, 2021
1 parent 3b481af commit d0df754
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions testing/databaseTest.py
Expand Up @@ -133,6 +133,12 @@ def test_kinetics(self):
self.compat_func_name = test_name
yield test, family_name

test = lambda x: self.kinetics_check_coverage_dependence_units_are_correct(family_name)
test_name = "Kinetics surface family {0}: check coverage dependent units are correct?".format(family_name)
test.description = test_name
self.compat_func_name = test_name
yield test, family_name

# these families have some sort of difficulty which prevents us from testing accessibility right now
difficult_families = ['Diels_alder_addition', 'Intra_R_Add_Exocyclic', 'Intra_R_Add_Endocyclic', 'Retroene']
generated_trees = ["R_Recombination"]
Expand Down Expand Up @@ -429,6 +435,32 @@ def general_check_metal_database_has_reasonable_labels(self, library):
if not entry.label[0].isupper():
raise NameError('Entry {} should start with a capital letter'.format(entry.label))

def kinetics_check_coverage_dependence_units_are_correct(self, family_name):
"""Test that each surface training reaction that has coverage dependent parameters has acceptable units"""
family = self.database.kinetics.families[family_name]
training = family.get_training_depository().entries.values()
failed = False

for entry in training:
cov_dep = entry.data.cov
if cov_dep:
assert isinstance(cov_dep, dict)
for species, parameters in cov_dep.items():
assert isinstance(species, str)
assert parameters['E']
if parameters['a'].units:
"Should be dimensionless"
failed = True
logging.error(f"Entry {entry.label} has invalid units {parameters['a'].units} for a")
if parameters['m'].units:
"Should be dimensionless"
failed = True
logging.error(f"Entry {entry.label} has invalid units {parameters['m'].units} for m")

if failed:
raise ValueError('Surface coverage dependent parameters have incorrect units.'
'Please check log warnings for all error messages.')

def kinetics_check_training_reactions_have_surface_attributes(self, family_name):
"""Test that each surface training reaction has surface attributes"""
family = self.database.kinetics.families[family_name]
Expand Down

0 comments on commit d0df754

Please sign in to comment.