Skip to content

Commit

Permalink
fix: restore list coupling map
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd committed Feb 15, 2022
1 parent c798b19 commit 8dd9eb9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions qiskit_rigetti/_qcs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
from typing import Optional, Any, Union, List, cast
from typing import Optional, Any, Union, List, cast, Tuple
from uuid import uuid4
import copy

Expand Down Expand Up @@ -84,7 +84,7 @@ def _prepare_circuit(circuit: QuantumCircuit) -> QuantumCircuit:
"""
Returns a prepared copy of the circuit for execution on the QCS Backend.
"""
if hasattr(circuit, 'copy'):
if hasattr(circuit, "copy"):
circuit = circuit.copy()
else:
circuit = copy.deepcopy(circuit)
Expand Down Expand Up @@ -203,5 +203,5 @@ def run(
)


def get_coupling_map_from_qc_topology(qc: QuantumComputer) -> CouplingMap:
return CouplingMap(qc.quantum_processor.qubit_topology().to_directed().edges())
def get_coupling_map_from_qc_topology(qc: QuantumComputer) -> List[Tuple[int, int]]:
return cast(List[Tuple[int, int]], qc.quantum_processor.qubit_topology().to_directed().edges())
13 changes: 6 additions & 7 deletions tests/test_qcs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def test_run(backend: RigettiQCSBackend):
circuit = make_circuit()

job = execute(circuit, backend, shots=10, coupling_map=backend.configuration().coupling_map)
job = execute(circuit, backend, shots=10)

assert job.backend() is backend
result = job.result()
Expand All @@ -39,7 +39,7 @@ def test_run__multiple_circuits(backend: RigettiQCSBackend):
circuit1 = make_circuit(num_qubits=2)
circuit2 = make_circuit(num_qubits=3)

job = execute([circuit1, circuit2], backend, shots=10, coupling_map=backend.configuration().coupling_map)
job = execute([circuit1, circuit2], backend, shots=10)

assert job.backend() is backend
result = job.result()
Expand Down Expand Up @@ -76,7 +76,6 @@ def test_run__parametric_circuits(backend: RigettiQCSBackend):
{t: 1.0},
{t: 2.0},
],
coupling_map=backend.configuration().coupling_map,
)

assert job.backend() is backend
Expand Down Expand Up @@ -108,7 +107,7 @@ def test_run__readout_register_not_named_ro(backend: RigettiQCSBackend):
circuit.measure([0, 1], [0, 1])
qasm_before = circuit.qasm()

job = execute(circuit, backend, shots=10, coupling_map=backend.configuration().coupling_map)
job = execute(circuit, backend, shots=10)

assert circuit.qasm() == qasm_before, "should not modify original circuit"

Expand All @@ -127,7 +126,7 @@ def test_run__multiple_registers__single_readout(backend: RigettiQCSBackend):
circuit.measure([0, 1], [readout_reg[0], readout_reg[1]])
qasm_before = circuit.qasm()

job = execute(circuit, backend, shots=10, coupling_map=backend.configuration().coupling_map)
job = execute(circuit, backend, shots=10)

assert circuit.qasm() == qasm_before, "should not modify original circuit"

Expand All @@ -148,7 +147,7 @@ def test_run__multiple_readout_registers(backend: RigettiQCSBackend):
circuit.measure([qr[0], qr[1]], [cr[0], cr2[0]])

with pytest.raises(RuntimeError, match="Multiple readout registers are unsupported on QCSBackend; found c, c2"):
execute(circuit, backend, shots=10, coupling_map=backend.configuration().coupling_map)
execute(circuit, backend, shots=10)


def test_run__no_measurments(backend: RigettiQCSBackend):
Expand All @@ -157,7 +156,7 @@ def test_run__no_measurments(backend: RigettiQCSBackend):
circuit = QuantumCircuit(qr, cr)

with pytest.raises(RuntimeError, match="Circuit has no measurements"):
execute(circuit, backend, shots=10, coupling_map=backend.configuration().coupling_map)
execute(circuit, backend, shots=10)


def test_run__backend_coupling_map():
Expand Down
5 changes: 2 additions & 3 deletions tests/test_qcs_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ def test_run__backend_coupling_map():
("http://example.com/qvm",),
("http://localhost:9999/qvm",),
("http://127.0.0.1:9999/qvm",),
]
],
)
def test_get_simulator__remote(monkeypatch, qvm_url):
print("URL", qvm_url)
def test_get_simulator__remote(qvm_url, monkeypatch):
monkeypatch.setenv("QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL", qvm_url)

with pytest.raises(GetQuantumProcessorException):
Expand Down

0 comments on commit 8dd9eb9

Please sign in to comment.