Skip to content

Commit aea6ee1

Browse files
authored
Mark a few more tests as slow (#1292)
Some of the tests are extremely time-consuming on even a fast parallel Linux VM. Two of tests marked in this commit clocked in at **20 minutes each** even when running with `-n 30`. The following numbers are from using the pytest `--durations` option: * 1288.49s call src/openfermion/ops/representations/doci_hamiltonian_test.py::IntegralTransformsTest::test_fermionic_hamiltonian_from_integrals * 1208.20s call src/openfermion/transforms/opconversions/remove_symmetry_qubits_test.py::ReduceSymmetryQubitsTest::test_energy_reduce_symmetry_qubits Two other tests were in the 600-700 sec range, and they are marked as slow in this PR as well. The use of `@pytest.mark.slow` allows the user to run pytest with `-m "not slow"` to skip the these tests and some other tests in OpenFermion that are already marked as slow. Note: the changes to the imports are purely formatting/linting changes brought about by running check/format-incremental.
1 parent a858c48 commit aea6ee1

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/openfermion/ops/representations/doci_hamiltonian_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717

1818
import numpy
19+
import pytest
1920

2021
from openfermion.config import EQ_TOLERANCE
2122
from openfermion.chem.molecular_data import MolecularData
@@ -24,11 +25,9 @@
2425
from openfermion.linalg import get_sparse_operator
2526
from openfermion.ops.representations.doci_hamiltonian import (
2627
DOCIHamiltonian,
27-
get_tensors_from_doci,
28-
get_projected_integrals_from_doci,
2928
get_doci_from_integrals,
3029
)
31-
from openfermion import get_fermion_operator, InteractionOperator, normal_ordered
30+
from openfermion import get_fermion_operator, InteractionOperator
3231

3332
numpy.set_printoptions(linewidth=2000, threshold=sys.maxsize)
3433

@@ -55,6 +54,7 @@ def test_integrals_self_inverse(self):
5554
self.assertTrue(numpy.allclose(hr1, hr1_test))
5655
self.assertTrue(numpy.allclose(hr2, hr2_test))
5756

57+
@pytest.mark.slow
5858
def test_fermionic_hamiltonian_from_integrals(self):
5959
constant = self.molecule.nuclear_repulsion
6060
doci_constant = constant

src/openfermion/resource_estimates/pbc/thc/factorizations/isdf_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
13+
1314
import numpy as np
1415
import pytest
1516

@@ -253,6 +254,7 @@ def test_G_vector_mapping_single_translation():
253254

254255

255256
@pytest.mark.skipif(not HAVE_DEPS_FOR_RESOURCE_ESTIMATES, reason='pyscf and/or jax not installed.')
257+
@pytest.mark.slow
256258
def test_kpoint_isdf_double_translation():
257259
cell = gto.Cell()
258260
cell.atom = """
@@ -300,6 +302,7 @@ def test_kpoint_isdf_double_translation():
300302

301303

302304
@pytest.mark.skipif(not HAVE_DEPS_FOR_RESOURCE_ESTIMATES, reason='pyscf and/or jax not installed.')
305+
@pytest.mark.slow
303306
def test_kpoint_isdf_single_translation():
304307
cell = gto.Cell()
305308
cell.atom = """

src/openfermion/transforms/opconversions/remove_symmetry_qubits_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import unittest
1818

19+
import pytest
20+
1921
from openfermion.hamiltonians import fermi_hubbard
2022
from openfermion.chem import MolecularData
2123
from openfermion.transforms.opconversions import get_fermion_operator
@@ -83,6 +85,7 @@ def number_of_qubits(qubit_hamiltonian, unreduced_orbitals):
8385
class ReduceSymmetryQubitsTest(unittest.TestCase):
8486
# Check whether fermionic and reduced qubit Hamiltonians
8587
# have the same energy for LiH
88+
@pytest.mark.slow
8689
def test_energy_reduce_symmetry_qubits(self):
8790
# Generate the fermionic Hamiltonians,
8891
# number of orbitals and number of electrons.

0 commit comments

Comments
 (0)