Skip to content

Commit

Permalink
Update tests for gurobipy 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbowly committed Oct 24, 2024
1 parent 88ab828 commit 12d1da4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,27 +228,28 @@ def test_linexpr_varseries(self):
self.assert_expression_equal(result[i], 2 * y * x[i])

def test_dataseries_quadexpr(self):
s = pd.Series(list(range(5)))
s = pd.Series(list(range(1, 6)))
y = self.model.addVar(name="y")
qe = y * y
self.model.update()
result = s * qe
self.assertIsInstance(result, pd.Series)
for i in range(5):
self.assert_expression_equal(result[i], i * y * y)
self.assert_expression_equal(result[i], (i + 1) * y * y)

@unittest.skipIf(GUROBIPY_MAJOR_VERSION < 10, "Operator precedence in v9")
def test_quadexpr_dataseries(self):
s = pd.Series(list(range(5)))
s = pd.Series(list(range(1, 6)))
y = self.model.addVar(name="y")
qe = y * y
self.model.update()
result = qe * s
self.assertIsInstance(result, pd.Series)
for i in range(5):
self.assert_expression_equal(result[i], i * y * y)
self.assert_expression_equal(result[i], (i + 1) * y * y)

def test_varseries_quadexpr(self):
@unittest.skipIf(GUROBIPY_MAJOR_VERSION >= 12, "NLExpr takes over in v12")
def test_varseries_quadexpr_fail(self):
# Cannot multiply, should get a GurobiError
# (Note in gurobipy, QuadExpr * QuadExpr is technically allowed as long
# as it won't introduce degree > 2 terms)
Expand Down

0 comments on commit 12d1da4

Please sign in to comment.