From 137c68b699640db4506565e49bea3857d03c5437 Mon Sep 17 00:00:00 2001 From: jonasleitner Date: Tue, 28 Jan 2025 09:04:20 +0100 Subject: [PATCH] reduce number of tests --- .gitmodules | 3 --- tests/AdcMatrix_test.py | 11 ++++++----- tests/ExcitedStates_test.py | 4 ++-- tests/ReferenceState_backends_test.py | 11 ++++++----- tests/adc_pp/modified_transition_moments_test.py | 1 - tests/functionality_test.py | 2 +- tests/guess_test.py | 2 +- tests/properties_test.py | 13 ++++++++++--- tests/state_densities_test.py | 9 ++++++++- 9 files changed, 34 insertions(+), 22 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7c68c3fd..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "adcc/testdata/adcc-testdata"] - path = adcc/testdata/adcc-testdata - url = https://github.com/adc-connect/adcc-testdata.git diff --git a/tests/AdcMatrix_test.py b/tests/AdcMatrix_test.py index 786f8e29..d3ec88bd 100644 --- a/tests/AdcMatrix_test.py +++ b/tests/AdcMatrix_test.py @@ -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( @@ -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) diff --git a/tests/ExcitedStates_test.py b/tests/ExcitedStates_test.py index f9f8538b..b2c07679 100644 --- a/tests/ExcitedStates_test.py +++ b/tests/ExcitedStates_test.py @@ -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 ) diff --git a/tests/ReferenceState_backends_test.py b/tests/ReferenceState_backends_test.py index c145c6d1..90d4bb22 100644 --- a/tests/ReferenceState_backends_test.py +++ b/tests/ReferenceState_backends_test.py @@ -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": diff --git a/tests/adc_pp/modified_transition_moments_test.py b/tests/adc_pp/modified_transition_moments_test.py index 40448ced..be431d40 100644 --- a/tests/adc_pp/modified_transition_moments_test.py +++ b/tests/adc_pp/modified_transition_moments_test.py @@ -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] diff --git a/tests/functionality_test.py b/tests/functionality_test.py index 2e5281a4..44f442ff 100644 --- a/tests/functionality_test.py +++ b/tests/functionality_test.py @@ -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 ] diff --git a/tests/guess_test.py b/tests/guess_test.py index d324067e..6463500c 100644 --- a/tests/guess_test.py +++ b/tests/guess_test.py @@ -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( diff --git a/tests/properties_test.py b/tests/properties_test.py index 5b292dc9..44ec1570 100644 --- a/tests/properties_test.py +++ b/tests/properties_test.py @@ -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) diff --git a/tests/state_densities_test.py b/tests/state_densities_test.py index 0f31ad3d..b2e8954d 100644 --- a/tests/state_densities_test.py +++ b/tests/state_densities_test.py @@ -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)