From b2e936830d174013434d58f124487a1cbcaefb53 Mon Sep 17 00:00:00 2001 From: Guillaume Schurck Date: Thu, 7 Nov 2024 14:56:42 +0100 Subject: [PATCH] test(local): passing custom A&B options to backend.run() is not allowed --- tests/local/test_backend.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/local/test_backend.py b/tests/local/test_backend.py index 8c53470..246e4cb 100644 --- a/tests/local/test_backend.py +++ b/tests/local/test_backend.py @@ -1,10 +1,12 @@ from typing import List import numpy as np +import pytest from qiskit import QuantumCircuit, transpile from qiskit.circuit.library import Initialize from qiskit_alice_bob_provider.local.backend import ProcessorSimulator +from qiskit_alice_bob_provider.processor.logical_cat import LogicalCatProcessor from qiskit_alice_bob_provider.processor.physical_cat import ( PhysicalCatProcessor, ) @@ -43,6 +45,26 @@ def test_set_execution_backend_options() -> None: assert sum(backend.run(transpiled).result().get_counts().values()) == 7 +def test_run_override_nbar_error() -> None: + """ + Test that passing average_nb_photons option to backend.run() is not allowed + """ + circ = QuantumCircuit(1, 1) + backend = ProcessorSimulator(PhysicalCatProcessor()) + transpiled = transpile(circ, backend) + with pytest.raises(ValueError): + _ = backend.run(transpiled, shots=100, average_nb_photons=4) + with pytest.raises(ValueError): + _ = backend.run(transpiled, shots=100, kappa_1=4) + + backend = ProcessorSimulator(LogicalCatProcessor()) + transpiled = transpile(circ, backend) + with pytest.raises(ValueError): + _ = backend.run(transpiled, shots=100, average_nb_photons=4) + with pytest.raises(ValueError): + _ = backend.run(transpiled, shots=100, kappa_1=4) + + def test_translation_plugin() -> None: backend = ProcessorSimulator(SimpleProcessor(1))