Skip to content

Commit a220ae4

Browse files
committed
Use numpy array comparisons in tests
Replace usages of built-in all(...) with np.array_equal(...) to correctly compare array-like results from m.getSolVal and m.getVal. Import numpy as np and construct the expected value as np.array([0, 0]). Also remove an unused itertools import and reorder pyscipopt imports for clarity.
1 parent 5fff107 commit a220ae4

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

tests/test_model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import pytest
2-
import os
31
import itertools
2+
import os
43

5-
from pyscipopt import Model, SCIP_STAGE, SCIP_PARAMSETTING, SCIP_BRANCHDIR, quicksum
4+
import numpy as np
5+
import pytest
66
from helpers.utils import random_mip_1
77

8+
from pyscipopt import SCIP_BRANCHDIR, SCIP_PARAMSETTING, SCIP_STAGE, Model, quicksum
9+
10+
811
def test_model():
912
# create solver instance
1013
s = Model()
@@ -632,8 +635,8 @@ def test_getSolVal():
632635
assert m.getSolVal(sol, x) == m.getVal(x)
633636
assert m.getVal(x) == 0
634637

635-
assert all(m.getSolVal(sol, y) == m.getVal(y))
636-
assert all(m.getVal(y) == [0, 0])
638+
assert np.array_equal(m.getSolVal(sol, y), m.getVal(y))
639+
assert np.array_equal(m.getVal(y), np.array([0, 0]))
637640

638641
with pytest.raises(TypeError):
639642
m.getVal("not_a_var")

0 commit comments

Comments
 (0)