Skip to content

Commit

Permalink
Include warning checks in molden unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed Jun 7, 2024
1 parent 4437bbf commit 7a36737
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions iodata/test/test_molden.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,30 +260,34 @@ def test_load_molden_nh3_molden_cart():
assert_allclose(charges, molden_charges, atol=1.0e-3)


def test_load_molden_cfour():
# The file tested here is created with CFOUR 2.1.
file_list = [
"h_sonly_sph_cfour.molden",
"h_ponly_sph_cfour.molden",
"h_donly_sph_cfour.molden",
"h_fonly_sph_cfour.molden",
"h_gonly_sph_cfour.molden",
"h_sonly_cart_cfour.molden",
"h_ponly_cart_cfour.molden",
"h_donly_cart_cfour.molden",
"h_fonly_cart_cfour.molden",
"h_gonly_cart_cfour.molden",
"h2o_ccpvdz_cfour.molden",
]

for i in file_list:
with as_file(files("iodata.test.data").joinpath(i)) as fn_molden:
print(str(fn_molden))
# The file tested here is created with CFOUR 2.1.
@pytest.mark.parametrize(
("path", "should_warn"),
[
("h_sonly_sph_cfour.molden", False),
("h_ponly_sph_cfour.molden", False),
("h_donly_sph_cfour.molden", True),
("h_fonly_sph_cfour.molden", True),
("h_gonly_sph_cfour.molden", True),
("h_sonly_cart_cfour.molden", False),
("h_ponly_cart_cfour.molden", False),
("h_donly_cart_cfour.molden", True),
("h_fonly_cart_cfour.molden", True),
("h_gonly_cart_cfour.molden", True),
("h2o_ccpvdz_cfour.molden", True),
],
)
def test_load_molden_cfour(path, should_warn):
with as_file(files("iodata.test.data").joinpath(path)) as fn_molden:
if should_warn:
with pytest.warns(FileFormatWarning):
mol = load_one(str(fn_molden))
else:
mol = load_one(str(fn_molden))
# Check normalization
olp = compute_overlap(mol.obasis, mol.atcoords)
check_orthonormal(mol.mo.coeffsa, olp)
check_orthonormal(mol.mo.coeffsb, olp)
# Check normalization
olp = compute_overlap(mol.obasis, mol.atcoords)
check_orthonormal(mol.mo.coeffsa, olp)
check_orthonormal(mol.mo.coeffsb, olp)


def test_load_molden_nh3_orca():
Expand Down

0 comments on commit 7a36737

Please sign in to comment.