Open bernalde opened 3 years ago
I reinstalled an environment with python 3.8 and it does not solve the issue, so the problem might be somewhere else.
Hi, I suspect the problem is with the shape of h
. I think the BQM constructor is looking for a sequence as opposed to a 2D array:
h = np.random.rand(N)
FYI, I believe you can also construct the model directly using:
model_random = dimod.BinaryQuadraticModel(h, J, 'SPIN')
@mcfarljm is correct. Though I think we could add a better error message. I'll make a PR to do so.
Thank you for looking into this. The solution works just fine, but I wanted to make you aware of this since it worked on a previous version of dimod.
Ah, interesting, I didn't realize it was a backwards compatibility break (though I should have from your original post). Ok, I'll see if we can restore the behavior. Worst case we can still just raise a better error message.
Description As detailed in the title and MWE example, this code is failing.
Steps To Reproduce This is a MWE
Which prints:
I have debugged it down to line 223 in the
cybqm_template.pyx.pxi
cpdef Py_ssize_t add_linear_from_array(self, ConstNumeric[:] linear) except -1:
...Expected Behavior In previous versions of Python, it works well, so my guess is that Python 3.9 makes some type assumptions that are leading to this error. Something along this post in Stack overflow.
Environment
Additional Context Add any other background information about the problem.