Skip to content

Commit

Permalink
test(local): passing custom A&B options to backend.run() is not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
gschurck committed Nov 21, 2024
1 parent 0e9b8cf commit b2e9368
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/local/test_backend.py
Original file line number Diff line number Diff line change
@@ -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,
)
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit b2e9368

Please sign in to comment.