The test failures are in one of the comments in
I don't know scipy.sparse well enough to say if this is an actual regression, but I can replicate the test failures. Maybe it's just problems in the cvxpy project in which case this issue can be closed.
I'm not able to reproduce the test failures. How do you reproduce them?
Works for me with Numpy 1.8.0, Scipy 0.14.0.dev-7cefb25 (current master), with 1.7.1 + 0.14.0.dev-7cefb25, and with 1.7.1 + 0.13.3.
Does not work with Scipy 0.12.0.
@pv the test failures are with the development branches of numpy and scipy, and it's possible that I'm reproducing a failure to install numpy/scipy correctly :)
Maybe the problem is bad installation, or just a problem in cvxpy, or maybe a numpy regression, or maybe a regression in the interaction between numpy and scipy. Only the latter situation would be interesting here.
Ok, the issue seems to be that cvxopt relies on this behavior:
import numpy as np
from scipy.sparse import csr_matrix
np.multiply(csr_matrix([[1, 2]]), np.array([csr_matrix([, ])], dtype=object))
# -> array([ <1x1 sparse matrix of type '<type 'numpy.int64'>'
# with 1 stored elements in Compressed Sparse Row format>], dtype=object)
In Numpy 1.9.0-dev + Scipy 0.14.0-dev this gets routed to csr_matrix.__numpy_ufunc__, which does something undefined with the object array arg.
Previously, this did np.array([a.__mul__(b) for b in rhs], dtype=object).
This behavior is recovered by explicitly casting also the first arg to object array
np.array([a.__mul__(b) for b in rhs], dtype=object)
np.multiply(np.array(csr_matrix([[1, 2]]), dtype=object),
np.array([csr_matrix([, ])], dtype=object))
adjusted readme to reflect issues with newest numpy,scipy
BUG: sparse: restore previous behavior in numpy ufuncs with object ar…
Some users may rely on ufuncs distributing operations on sparse matrices
across each entry of an object array.
Previous behavior vs. object arrays restored in gh-3346 (fixes cvxopt test failures).
The previous behavior was quite glitchy, however:
>>> np.multiply(np.array([csr_matrix([, ])], dtype=object), csr_matrix([[1, 2]]))
The recommendation to people relying on this is to not rely on automatic
casts to object arrays, but to cast explicitly.