New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestDicke fails with scipy 1.6.1: TypeError: can't convert complex to float #1451
Comments
It's probably relevant that scipy 1.6.1 fixed some problems with sparse matrices (with COO format constructor), see https://docs.scipy.org/doc/scipy-1.6.1/reference/release.1.6.1.html including PR#13403 scipy/scipy#13403 |
Thanks for the bug report and the detailed look into it! As a temporary work-around, in file Lines 431 to 433 in 2aaae75
cdef lindblad_matrix = csr_matrix((lindblad_data,
(lindblad_row, lindblad_col)),
shape=(nds**2, nds**2),
dtype=np.complex128) and recompile. If you want to make a PR of something similar against QuTiP, I'll accept it. I would actually file this against Basic Scipy reproducer to illustrate the problem: >>> import scipy.sparse
>>> scipy.__version__
'1.6.1'
>>> scipy.sparse.csr_matrix(([1+1j], ([0], [0])), shape=(2, 2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jake/.anaconda3/envs/qutip-dev/lib/python3.8/site-packages/scipy/sparse/compressed.py", line 54, in __init__
other = self.__class__(coo_matrix(arg1, shape=shape,
File "/Users/jake/.anaconda3/envs/qutip-dev/lib/python3.8/site-packages/scipy/sparse/coo.py", line 161, in __init__
self.data = np.array(obj, copy=copy, dtype=data_dtype)
TypeError: can't convert complex to float This can be fixed either by passing I imagine with their implicit conversions, SciPy may also need to test the special cases where all list elements are things like |
Note: they're already talking about a change in scipy/scipy#13585 and scipy/scipy#13586. I'll post this repro on the bottom of that. |
Thanks for the speedy response @jakelishman . Looks like scipy 1.6.1 is not quite as stable as we would have liked it to have been. I'll wait for the scipy dust to settle. |
We can still merge the workaround into qutip if you'd like to make the PR (otherwise I'll take care of it). There's no harm in being explicit since we know we will always want complex dtype. |
Agreed, safer to make it explicit. I'll prepare a PR. |
Required due to changes in scipy 1.6.1. Using an explicit dtype will make matrix construction more robust. Fixes qutip Issue qutip#1451.
Hi @jakelishman , cqobjevo.pyx also uses |
Numpy interprets the Python base type |
No worries, I'll stick with just piq.pyx then. |
Required due to changes in scipy 1.6.1. Using an explicit dtype will make matrix construction more robust. Fixes qutip Issue qutip#1451.
Some TestDicke tests in
test_piqs.py
(test_lindbladian, test_lindbladian_dims, test_liouvillian) fail with the recent scipy 1.6.1 release. They were previously passing with scipy 1.6.0.To Reproduce
The test error message from
TestDicke.test_lindbladian
isLikewise for
TestDicke.test_lindbladian_dims
andTestDicke.test_liouvillian
.Your Environment
qutip 4.5.3 built on Debian unstable.
The text was updated successfully, but these errors were encountered: