Skip to content

Commit

Permalink
Fix: Handle older versions of qasm that do not implement copy
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd authored and dbanty committed May 26, 2022
1 parent 0868dcc commit 3fd0091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion qiskit_rigetti/_qcs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
##############################################################################
from typing import Optional, Any, Union, List, cast, Tuple
from uuid import uuid4
import copy

from pyquil import get_qc
from pyquil.api import QuantumComputer, EngagementManager
Expand Down Expand Up @@ -82,7 +83,10 @@ def _prepare_circuit(circuit: QuantumCircuit) -> QuantumCircuit:
"""
Returns a prepared copy of the circuit for execution on the QCS Backend.
"""
circuit = circuit.copy()
if hasattr(circuit, "copy"):
circuit = circuit.copy()
else:
circuit = copy.deepcopy(circuit)
_prepare_readouts(circuit)
return circuit

Expand Down
4 changes: 2 additions & 2 deletions tests/test_qcs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ def test_run__no_measurments(backend: RigettiQCSBackend):
def test_run__backend_coupling_map():
backend = RigettiQCSProvider().get_simulator(num_qubits=3)
assert backend.configuration().coupling_map
assert [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)] == sorted(backend.configuration().coupling_map)
assert [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)] == sorted(list(backend.configuration().coupling_map))


def test_run__backend_coupling_map():
backend = RigettiQCSProvider().get_simulator(num_qubits=3)
assert backend.configuration().coupling_map
assert [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)] == sorted(backend.configuration().coupling_map)
assert [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)] == sorted(list(backend.configuration().coupling_map))


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_qcs_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_run__backend_coupling_map():
("http://127.0.0.1:9999/qvm",),
],
)
def test_get_simulator__remote(monkeypatch, 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 3fd0091

Please sign in to comment.