Skip to content

Commit

Permalink
Add CouplingMap to encoder (#2026)
Browse files Browse the repository at this point in the history
* Encode/decode CouplingMap

* Convert coupling map to list

* Add release note
  • Loading branch information
kt474 authored Nov 11, 2024
1 parent c28c7e1 commit 1f2a874
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qiskit_ibm_runtime/utils/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
QuantumCircuit,
QuantumRegister,
)
from qiskit.transpiler import CouplingMap
from qiskit.circuit.parametertable import ParameterView
from qiskit.result import Result
from qiskit.version import __version__ as _terra_version_string
Expand Down Expand Up @@ -236,6 +237,8 @@ class RuntimeEncoder(json.JSONEncoder):
"""JSON Encoder used by runtime service."""

def default(self, obj: Any) -> Any: # pylint: disable=arguments-differ
if isinstance(obj, CouplingMap):
return list(obj)
if isinstance(obj, date):
return {"__type__": "datetime", "__value__": obj.isoformat()}
if isinstance(obj, complex):
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/2026.bug.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``CouplingMap`` was added to :class:`~.RuntimeEncoder` so it can now be passed to
the :class:`~.NoiseLearner` program.

0 comments on commit 1f2a874

Please sign in to comment.