Skip to content

Commit

Permalink
add recursive test case and div/mul cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout4 committed Nov 9, 2023
1 parent b01370d commit 3033c18
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_trans_linearize.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def test_sum(self):
cons = canonical_comparison([cp.sum([a,b,c,10]) <= rhs])[0]
self.assertEqual("sum([a, b, c]) <= -5", str(cons))

cons = canonical_comparison([(cp.sum([a, b, c, 10]) <= rhs) == (cp.sum([a]) <= b)])[0]
self.assertEqual('(sum([a, b, c]) <= -5) == (sum([1, -1] * [a, b]) <= 0)', str(cons))

rhs = cp.sum([b,c])
cons = canonical_comparison([cp.sum([a, b]) <= rhs])[0]
self.assertEqual("sum([1, 1, -1, -1] * [a, b, b, c]) <= 0", str(cons))
Expand All @@ -209,8 +212,11 @@ def test_div(self):
self.assertEqual("(a) // (b) <= 5", str(cons))

#when adding division
#cons = canonical_comparison([a / b <= c / rhs])[0]
#cons = canonical_comparison([a + b <= c/rhs])[0]
cons = canonical_comparison([a / b <= c / rhs])[0]
self.assertEqual('?', str(cons))

cons = canonical_comparison([a + b <= c * a])[0]
self.assertEqual('(sum([a, b]) - c * a <= 0)', str(cons))


def test_wsum(self):
Expand Down

0 comments on commit 3033c18

Please sign in to comment.