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.
This also fails:
metadata = {"ev_qubits": np.fromiter([[0, 1], [0, 1, 2]], dtype=object)}
We should check if these examples still fail since it's been a while
We should check if these examples still fail since it's been a while
Looks like both of the examples given in this issue no longer fail