Skip to content

Commit b03cf22

Browse files
committed
take care of the corner case for all backends in the frontend
1 parent 2114066 commit b03cf22

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/sage/numerical/mip.pyx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ cdef class MixedIntegerLinearProgram(SageObject):
20592059
<BLANKLINE>
20602060
Constraints:
20612061
1.0 <= x_0 - x_1
2062-
-2.0 <= -2.0 x_0 + 2.0 x_1
2062+
-2.0 <= -2.0 x_0 + 2.0 x_1
20632063
Variables:
20642064
x_0 is a continuous variable (min=-oo, max=+oo)
20652065
x_1 is a continuous variable (min=-oo, max=+oo)
@@ -2275,11 +2275,20 @@ cdef class MixedIntegerLinearProgram(SageObject):
22752275
sage: for each in range(10): p.add_constraint(x - y, max = 10)
22762276
sage: p.number_of_constraints()
22772277
3
2278+
2279+
TESTS:
2280+
2281+
Removing no constraints does not make Sage crash, see
2282+
:trac:`34881`::
2283+
2284+
sage: MixedIntegerLinearProgram().remove_constraints([])
2285+
22782286
"""
22792287
if self._check_redundant:
22802288
for i in sorted(constraints, reverse=True):
22812289
self._constraints.pop(i)
2282-
self._backend.remove_constraints(constraints)
2290+
if constraints:
2291+
self._backend.remove_constraints(constraints)
22832292

22842293
def set_binary(self, ee):
22852294
r"""

0 commit comments

Comments
 (0)