Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for object array encoding/decoding #1635

Open
ihincks opened this issue Apr 24, 2024 · 1 comment
Open

Add support for object array encoding/decoding #1635

ihincks opened this issue Apr 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ihincks
Copy link
Collaborator

ihincks commented Apr 24, 2024

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.

@ihincks ihincks added the enhancement New feature or request label Apr 24, 2024
@chriseclectic
Copy link
Member

This also fails:

metadata = {"ev_qubits": np.fromiter([[0, 1], [0, 1, 2]], dtype=object)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants