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
In [11]: np.asarray([0, 1])
Out[11]: array([0, 1])
However, for our purposes it would be convenient to handle it. So we can do constructions like
importnumpyasnpfromdwave.optimizationimportconcatenate, Modelmodel=Model()
symbols= [model.constant(0), model.constant(1)]
concatenate(symbols) # this doesn't work
for now it can be done with
importnumpyasnpfromdwave.optimizationimportconcatenate, Modelmodel=Model()
symbols= [model.constant(0), model.constant(1)]
concatenate(tuple(s.reshape((1,)) forsinsymbols)) # this works
The text was updated successfully, but these errors were encountered:
I should be less cryptic. Thinking about it more, I think what I actually want is numpy.stack(). That is, I want to combine $n$ 0d arrays (i.e. scalars) into a length $n$ 1d array. This can either be handled at the Python level via reshapes and concatenates or at the C++ level.
Implementing stack would be the better approach imo. But maybe a quicker solution for now is to go with the Python. Similar to what is in my PR, only that we should explicitly check that ndim is 0 before reshaping and not limit it to constants since we'd also probably want concatenate([model.binary(), model.binary()]) to work
NumPy's
concatenate()
does not handle scalarsI assume this is because you can simply do
However, for our purposes it would be convenient to handle it. So we can do constructions like
for now it can be done with
The text was updated successfully, but these errors were encountered: