From 12d1da45b2cfa58e7a7b16281c47f1449c495428 Mon Sep 17 00:00:00 2001 From: Simon Bowly Date: Thu, 24 Oct 2024 16:19:54 +1100 Subject: [PATCH] Update tests for gurobipy 12.0 --- tests/test_operators.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_operators.py b/tests/test_operators.py index d059486..8c7fb61 100644 --- a/tests/test_operators.py +++ b/tests/test_operators.py @@ -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)