Search code examples
pythonexpressioncvxpy

CVXPY expression doesn't give expected result


I am using CVXPY (version 1.0). I do not understand what causes the difference between a ZERO expression and a NONNEGATIVE expression as demonstrated by the following code:

>>> import cvxpy as cv
>>> a = cv.Variable(1)
>>> b = cv.Variable(1)
>>> print((cv.square(a-b)*1/(1e-6)).__repr__()) 
Expression(CONSTANT, ZERO, (1,))
>>> print((cv.square(a-b)*float(1/1e-6)).__repr__()) 
Expression(CONVEX, NONNEGATIVE, (1,))

Solution

  • This is due to a bug that is now fixed in 1.0. Small values were being rounded to 0.