def benchmarker(): try: bm = get_benchmarker() bm.apply_clifford_to_pauli(Program(I(0)), sI(0)) except RequestException as e: return pytest.skip("This test requires a running local benchmarker endpoint (ie quilc): {}" .format(e))
def benchmarker(): try: bm = get_benchmarker(timeout=2) bm.apply_clifford_to_pauli(Program(I(0)), sX(0)) return bm except (RequestException, TimeoutError) as e: return pytest.skip("This test requires a running local benchmarker endpoint (ie quilc): {}" .format(e))
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. """Tests the RB circuits generated by benchmarking.py.""" import numpy as np import pytest from pyquil.api import get_benchmarker, get_qc from pyquil.gates import MEASURE from mitiq.mitiq_pyquil.benchmarking import generate_rb_program BENCHMARKER = get_benchmarker() QVM = get_qc("2q-qvm") def test_generate_rb_program_1q(): program = generate_rb_program(BENCHMARKER, [0], 4) ro = program.declare("ro", "BIT") program += MEASURE(0, ro[0]) assert np.allclose([[0]], QVM.run(program)) def test_generate_rb_program_2q(): program = generate_rb_program(BENCHMARKER, [0, 1], 4) ro = program.declare("ro", "BIT", 2) program += MEASURE(0, ro[0]) program += MEASURE(1, ro[1])