dwave-cloud-client
dwave-cloud-client copied to clipboard
`DWaveSampler().sample` can't parse numpy integers for `num_reads`
Description
DWaveSampler().sample(bqm, num_reads=np.int8(123))
gives an error.
Why np.int8(123)
? Occurs in scenarios such as np.linspace(2, 6, 10, dtype=np.int8)[0]
To Reproduce
this will fail with the following error: TypeError: Object of type int8 is not JSON serializable
from dwave.system import DWaveSampler
import numpy as np
sampler_dw = DWaveSampler(name='BAY8_P16_X_INTERNAL')
sampler_dw.sample_ising(h={30: 0}, J={}, num_reads=np.int8(1))
this will work:
from neal import SimulatedAnnealingSampler
sampler_sa = SimulatedAnnealingSampler()
sampler_sa.sample_ising(h={30: 0}, J={}, num_reads=np.int8(1))
Environment:
- OS: Ubuntu 18.04.6 LTS
- Python version: 3.9.7
- Ocean SDK: 4.3.0
- dimod: 0.10.10
- numpy: 1.22.0
- neal: 0.5.9
@randomir IMO we should migrate this issue to the cloud-client. Unless you think the DWaveSampler should be handling this case?
@arcondello, I agree. Sampling params are just passed down to the QPU solver, and we can handle conversion there.