Skip to content

Commit

Permalink
expand tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnaceBleukx committed May 31, 2024
1 parent 02adf0e commit 64a4908
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,19 @@ def test_all(self):
def test_multidim(self):

functions = ["all", "any", "max", "min", "sum", "prod"]
constraints = ["alldifferent", "alldifferent_except0", "allequal", "circuit",
"increasing", "increasing_strict", "decreasing", "decreasing_strict"]
bv = cp.boolvar(shape=(5,4,3,2)) # high dimensional tensor
iv = cp.intvar(0,10,shape=(5,4,3,2))
arr = np.zeros(shape=bv.shape) # numpy "ground truth"

for axis in range(len(bv.shape)):
np_res = arr.sum(axis=axis)
for func in functions:
cpm_res = getattr(bv, func)(axis=axis)
np_res = getattr(arr, func)(axis=axis)
self.assertEqual(cpm_res.shape, np_res.shape)
for cons in constraints:
cpm_res = getattr(iv, func)(axis=axis)
self.assertEqual(cpm_res.shape, np_res.shape)


Expand Down

0 comments on commit 64a4908

Please sign in to comment.