SFOpenBoson icon indicating copy to clipboard operation
SFOpenBoson copied to clipboard

VisibleDeprecationWarning from numpy

Open johnzl-777 opened this issue 3 years ago • 1 comments

Note: this is somewhat of a preemptive issue, assuming that the edits from #6 go through

Running:

>>> prog = sf.Program(2)
>>> with prog.context as q:
...     Fock(2) | q[1]
...     BoseHubbardPropagation(H, 1.086, 20) | q

from the Bose Hubbard Demo in the documentation will emit the following warning with numpy v1.21.4

auxillary.py:153: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.

I imagine (naively) that the fix involves inserting that dtype=object argument to the two np.array() calls on line 153:

ladders = np.array(list(np.array(group_list, dtype=object)[:, 1]), dtype=object)[:, :, 1]

johnzl-777 avatar Dec 15 '21 03:12 johnzl-777

Thanks for bringing this issue to our attention @johnzl-777! We will look into the PR that you've opened and get back to you soon.

thisac avatar Jan 27 '22 17:01 thisac