quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 373 forks source link

Slight increase in testing speed #689

Closed ncrubin closed 3 years ago

ncrubin commented 3 years ago

We might want to consider testing incrementally

ncrubin commented 3 years ago

Top 10 slow tests:

I only address the top two in this PR. Small change is to make test systems smaller.

python -m pytest --durations=10

Before:

21.75s call src/openfermion/linalg/wedge_product_test.py::test_random_two_wedge_two 18.39s call src/openfermion/measurements/fermion_partitioning_test.py::TestPairWithinSimultaneously::test_small 10.68s call src/openfermion/testing/lih_integration_test.py::LiHIntegrationTest::test_all 7.25s call src/openfermion/hamiltonians/plane_wave_hamiltonian_test.py::PlaneWaveHamiltonianTest::test_plane_wave_hamiltonian_bad_element 6.85s call src/openfermion/transforms/opconversions/remove_symmetry_qubits_test.py::ReduceSymmetryQubitsTest::test_energy_reduce_symmetry_qubits 5.04s call dev_tools/shell_tools_test.py::test_run_cmd_raise_on_fail 5.01s call src/openfermion/testing/performance_benchmarks_test.py::test_comm_diag_coulomb 4.98s call src/openfermion/testing/performance_benchmarks_test.py::test_run_diag_comm 4.49s call src/openfermion/hamiltonians/plane_wave_hamiltonian_test.py::PlaneWaveHamiltonianTest::test_plane_wave_hamiltonian_integration 4.43s call src/openfermion/linalg/erpa_test.py::test_erpa_eom_ham_lih

Total runtime (2:59)

After:

10.77s call src/openfermion/testing/lih_integration_test.py::LiHIntegrationTest::test_all 7.21s call src/openfermion/transforms/opconversions/remove_symmetry_qubits_test.py::ReduceSymmetryQubitsTest::test_energy_reduce_symmetry_qubits 7.21s call src/openfermion/hamiltonians/plane_wave_hamiltonian_test.py::PlaneWaveHamiltonianTest::test_plane_wave_hamiltonian_bad_element 5.00s call src/openfermion/testing/performance_benchmarks_test.py::test_comm_diag_coulomb 4.98s call src/openfermion/testing/performance_benchmarks_test.py::test_run_diag_comm 4.54s call src/openfermion/hamiltonians/plane_wave_hamiltonian_test.py::PlaneWaveHamiltonianTest::test_plane_wave_hamiltonian_integration 4.25s call src/openfermion/linalg/erpa_test.py::test_erpa_eom_ham_lih 3.60s call src/openfermion/circuits/trotter/hubbard_trotter_error_test.py::ErrorBoundTest::test_error_bound_using_info_odd_side_length_verbose 2.95s call src/openfermion/circuits/trotter/low_depth_trotter_error_test.py::ErrorBoundTest::test_error_bound_using_info_2d_verbose 2.44s call src/openfermion/linalg/sparse_tools_test.py::GetNumberPreservingSparseOperatorIntegrationTestLiH::test_number_restricted_spectra_match_molecule

(Total time: 2:16)

obriente commented 3 years ago

LGTM, the changes to fermion_partitioning are fine.