Skip to content

Commit

Permalink
reduce number of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasleitner committed Jan 28, 2025
1 parent 23c0c49 commit 137c68b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

11 changes: 6 additions & 5 deletions tests/AdcMatrix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
from . import testcases


test_cases = testcases.get_by_filename("h2o_sto3g", "cn_sto3g")
h2o_sto3g = testcases.get_by_filename("h2o_sto3g").pop()
cases = [(case.file_name, c) for case in test_cases for c in case.cases]
methods = ["adc0", "adc1", "adc2", "adc2x", "adc3"]


# Distinct implementations of the matrix equations only exist for the cases
# "gen" and "cvs".
@pytest.mark.parametrize("method", methods)
@pytest.mark.parametrize("system,case", cases)
@pytest.mark.parametrize("case", ["gen", "cvs"])
@pytest.mark.parametrize("system", ["h2o_sto3g", "cn_sto3g"])
class TestAdcMatrix:
def load_matrix_data(self, system: str, case: str, method: str) -> dict:
refdata = testdata_cache.adcc_data(
Expand Down Expand Up @@ -134,8 +135,8 @@ def test_compute_block(self, system: str, case: str, method: str):

class TestAdcMatrixInterface:
@pytest.mark.parametrize("method", methods)
@pytest.mark.parametrize("system,case",
[("h2o_sto3g", c) for c in h2o_sto3g.cases])
@pytest.mark.parametrize("case", h2o_sto3g.cases)
@pytest.mark.parametrize("system", ["h2o_sto3g"])
def test_properties(self, system: str, case: str, method: str):
reference_state = testdata_cache.refstate(system=system, case=case)
ground_state = adcc.LazyMp(reference_state)
Expand Down
4 changes: 2 additions & 2 deletions tests/ExcitedStates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_excitation_view(self, system: str, case: str, method: str, kind: str):
else:
assert_allclose(ref, res)

def test_custom_excitation_energy_correctios(self, system: str, case: str,
method: str, kind: str):
def test_custom_excitation_energy_corrections(self, system: str, case: str,
method: str, kind: str):
state = testdata_cache.adcc_states(
system=system, method=method, kind=kind, case=case
)
Expand Down
11 changes: 6 additions & 5 deletions tests/ReferenceState_backends_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
@pytest.mark.parametrize("backend", backends)
def test_backends_import_reference_data(system: str, case: str, backend: str):
system: testcases.TestCase = testcases.get_by_filename(system).pop()
if system.basis == "def2-tzvp" and system.name == "h2o" and \
backend == "veloxchem":
pytest.skip("VeloxChem does not support f-functions.")
if system.multiplicity == 2:
pytest.skip("VeloxChem does not support UHF.")

if backend == "veloxchem":
if system.basis == "def2-tzvp" and system.name == "h2o":
pytest.skip("VeloxChem does not support f-functions.")
if system.multiplicity != 1:
pytest.skip("VeloxChem does not support UHF.")

compare_eri = "abs"
if system.name == "cn":
Expand Down
1 change: 0 additions & 1 deletion tests/adc_pp/modified_transition_moments_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
test_cases = testcases.get_by_filename(
"h2o_sto3g", "h2o_def2tzvp", "cn_sto3g", "cn_ccpvdz"
)
assert all("gen" in case.cases and "cvs" in case.cases for case in test_cases)
cases = [(case.file_name, c, kind)
for case in test_cases for c in ["gen", "cvs"] for kind in case.kinds.pp]

Expand Down
2 changes: 1 addition & 1 deletion tests/functionality_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)
cases = [
(case.file_name, c, kind)
for case in test_cases for c in case.cases for kind in case.kinds["pp"]
for case in test_cases for c in case.cases for kind in case.kinds.pp
]


Expand Down
2 changes: 1 addition & 1 deletion tests/guess_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_singles_h2o(self, method: str, case: str):
@pytest.mark.parametrize("method", doubles_methods)
@pytest.mark.parametrize("case", h2o_sto3g.cases)
def test_doubles_h2o(self, method: str, case: str):
guesses = { # fewer guesses available?
guesses = { # fewer ocvv guesses available
"fv-cvs": 4, "fc-fv-cvs": 3
}
self.base_test_no_spin_change(
Expand Down
13 changes: 10 additions & 3 deletions tests/properties_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@
from . import testcases


methods = ["adc0", "adc1", "adc2", "adc2x", "adc3"]
# The density matrices are already tested in state_densities_test.py
# -> here we only want to test the contraction of the densities with
# the operator matrices
# -> independent of method, case (gen/cvs/fc/fv) and kind (singlet/triplet)
# Actually, the tests should also be independent of the systems, because
# we only load some already tested density and contract it with some operator.
methods = ["adc2"]
generators = ["adcman", "adcc"]

test_cases = testcases.get_by_filename(
"h2o_sto3g", "h2o_def2tzvp", "cn_sto3g", "cn_ccpvdz", "hf_631g"
)
cases = [(case.file_name, c, kind)
for case in test_cases for c in case.cases for kind in case.kinds.pp]
cases = [(case.file_name, "gen", kind)
for case in test_cases
for kind in ["singlet", "any", "spin_flip"] if kind in case.kinds.pp]


@pytest.mark.parametrize("method", methods)
Expand Down
9 changes: 8 additions & 1 deletion tests/state_densities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@
methods = ["adc0", "adc1", "adc2", "adc2x", "adc3"]
generators = ["adcman", "adcc"]


# There are only distinct density matrix implementations for the
# "gen" and "cvs" cases
# -> no need to test other cases (fc/fv)
# -> independent of state kind (singlet/triplet)
test_cases = testcases.get_by_filename(
"h2o_sto3g", "h2o_def2tzvp", "cn_sto3g", "cn_ccpvdz", "hf_631g"
)
cases = [(case.file_name, c, kind)
for case in test_cases for c in case.cases for kind in case.kinds.pp]
for case in test_cases
for c in ["gen", "cvs"] if c in case.cases
for kind in ["singlet", "any", "spin_flip"] if kind in case.kinds.pp]


@pytest.mark.parametrize("method", methods)
Expand Down

0 comments on commit 137c68b

Please sign in to comment.