Skip to content

Commit

Permalink
fix #1828
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDiamond committed Jul 18, 2022
1 parent 8cc75a8 commit d9559d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cvxpy/atoms/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def is_atom_concave(self) -> bool:
def is_atom_quasiconvex(self) -> bool:
"""Is the atom quasiconvex?
"""
return True
return self.args[0].is_scalar()

def is_atom_quasiconcave(self) -> bool:
"""Is the atom quasiconvex?
"""
return True
return self.args[0].is_scalar()

def is_incr(self, idx) -> bool:
"""Is the composition non-decreasing in argument idx?
Expand Down
8 changes: 8 additions & 0 deletions cvxpy/tests/test_dqcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ def test_sign(self) -> None:
cp.sign(variable).value
self.assertItemsAlmostEqual(value, variable.value)

# sign is only QCP for univariate input.
# See issue #1828
x = cp.Variable(2)
obj = cp.sum_squares(np.ones(2) - x)
constr = [cp.sum(cp.sign(x)) <= 1]
prob = cp.Problem(cp.Minimize(obj), constr)
assert not prob.is_dqcp()

def test_dist_ratio(self) -> None:
x = cp.Variable(2)
a = np.ones(2)
Expand Down

0 comments on commit d9559d5

Please sign in to comment.