qiskit-ibm-runtime
qiskit-ibm-runtime copied to clipboard
Add support for object array encoding/decoding
What is the expected feature or enhancement?
NumPy object arrays require special care when encoding/decoding. For example, the following fails:
import json
import numpy as np
from qiskit_ibm_runtime import RuntimeEncoder, RuntimeDecoder
metadata = {"ev_qubits": np.array([np.arange(2), np.arange(3)], dtype=object)}
js = json.dumps(metadata, cls=RuntimeEncoder)
json.loads(js, cls=RuntimeDecoder)
It successfully encodes, but then fails to decode because it can't figured out the raggedness.
cc @chriseclectic
Acceptance criteria
The above snippet succeeds, where the input to np.array
can also include other json-serializable Python builtins.