Skip to content

Commit

Permalink
Added QRE tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfleury-sb committed Aug 6, 2024
1 parent a746e28 commit ac032d8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ jobs:
python -m pip install openbabel-wheel
if: always()

- name: Install dependencies for QRE
run: |
pip install openfermionpyscf
pip install benchq
if: always()

- name: tangelo tests
run: |
cd tangelo
Expand Down
43 changes: 43 additions & 0 deletions tangelo/toolboxes/circuits/tests/test_qre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright SandboxAQ 2021-2024.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from tangelo.molecule_library import mol_H10_321g
from tangelo.toolboxes.circuits.qre import qre_benchq, qre_pennylane

class QRETest(unittest.TestCase):

def test_qre_benchq(self):
"""Test the QRE output type for the benchq interface."""

n_toffolis, n_qubits = qre_benchq(mol_H10_321g, 1e-6)

self.assertIsInstance(n_toffolis, int)
self.assertIsInstance(n_qubits, int)

# As done in tests/benchq/problem_embeddings/test_qpe.py in benchq repo.
self.assertGreater(n_qubits, mol_H10_321g.n_active_sos)

def test_qre_pennylane(self):
"""Test the QRE output type for the pennylane interface."""

output = qre_pennylane(mol_H10_321g)

self.assertIsInstance(output.gates, int)
self.assertIsInstance(output.qubits, int)


if __name__ == "__main__":
unittest.main()

0 comments on commit ac032d8

Please sign in to comment.