qiskit-ibm-runtime
qiskit-ibm-runtime copied to clipboard
Encoding/decoding does not work for `np.array(0, dtype=object)`
Describe the bug
An error occurs when encoding the object mentioned in the title and then decoding the resulting string.
TypeError: argument should be a bytes-like object or ASCII string, not 'int'
Steps to reproduce
obj = {"ndarray": np.array(0, dtype=object)}
encoded = json.dumps(obj, cls=RuntimeEncoder)
self.assertIsInstance(encoded, str)
decoded = json.loads(encoded, cls=RuntimeDecoder)
Expected behavior Object is properly enconded/decoded.
Additional Information Might be a good idea to add a (sub) test case here: https://github.com/Qiskit/qiskit-ibm-runtime/blob/6c2cf0e71b1273923086845d4383dc00cfa559f6/test/unit/test_data_serialization.py#L159-L163
- qiskit-ibm-runtime version: 0.18.0
- Python version: 3.11
- Operating system: MacOS