You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Users have expressed a desire to do operations like
fromdwave.optimizationimportModelmodel=Model()
array=model.constant(np.zeros(5, 5))
x=model.integer(5)
array[0, :] +=x# this raises an error
Unfortunately, due to the way that __setitem__ works in Python, we cannot give that exact syntax. But we can get pretty close. So the vision would be something like
The reason we can't use __setitem__ is that we need to create a new symbol/object, but there's no machinery for returning that with __setitem__, right?
Yes, __setitem__() always acts in-place on the object. Unlike say __iadd__() which can return a new object. It's possible we could do some fiddling with globals() or whatever, but that way lies madness and bugs.
It would also obscure the fact that you are making a new symbol every assignment which can clearly get expensive.
I'm slightly worried that a Put symbol would encourage use-cases that are better served by concatenation (so fewer intermediate arrays of "full-size"). But at least needing to call put and getting a new symbol back makes it clear that it's a full copy of the array.
Something like numpy.put().
Users have expressed a desire to do operations like
Unfortunately, due to the way that
__setitem__
works in Python, we cannot give that exact syntax. But we can get pretty close. So the vision would be something likeThe text was updated successfully, but these errors were encountered: