Skip to content

Commit

Permalink
Add tests for issue #80.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Jan 13, 2025
1 parent 75ff6ab commit 72c1ceb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/gmp/test_issue80.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from fractions import Fraction

import cdd.gmp

arr = [
[-Fraction(1, 20), 0, 0, 1, 0],
[Fraction(3, 2), 0, 0, -1, 0],
[0, 0, -Fraction(1, 3), -Fraction(32, 30), -Fraction(2, 3)],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 1],
[0, -1, 0, Fraction(3, 10), 1],
[0, 1, Fraction(2, 3), Fraction(16, 30), Fraction(1, 3)],
[0, 1, 0, 0, 0],
]


def test_empty_v_rep() -> None:
mat = cdd.gmp.matrix_from_array(arr, rep_type=cdd.RepType.INEQUALITY)
lin_set, red_set, indices = cdd.gmp.matrix_canonicalize(mat)
assert lin_set == {0, 1, 2, 3, 4, 5, 6, 7}
assert not red_set
assert indices == [0, 1, 2, 3, None, 4, None, None]
assert mat.lin_set == {0, 1, 2, 3, 4}
poly = cdd.gmp.polyhedron_from_matrix(mat)
v_rep = cdd.gmp.copy_output(poly)
assert not v_rep.array
24 changes: 24 additions & 0 deletions test/test_issue80.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import cdd

arr = [
[-0.05, -0.0, -0.0, 1.0, -0.0],
[1.5, -0.0, -0.0, -1.0, -0.0],
[0.0, -0.0, -0.3333333333333333, -1.0666666666666667, -0.6666666666666666],
[0.0, -0.0, 1.0, -0.0, -0.0],
[0.0, -0.0, -0.0, -0.0, 1.0],
[0.0, -1.0, -0.0, 0.3, 1.0],
[0.0, 1.0, 0.6666666666666666, 0.5333333333333333, 0.3333333333333333],
[0.0, 1.0, -0.0, -0.0, -0.0],
]


def test_empty_v_rep() -> None:
mat = cdd.matrix_from_array(arr, rep_type=cdd.RepType.INEQUALITY)
lin_set, red_set, indices = cdd.matrix_canonicalize(mat)
assert lin_set == {0, 1, 2, 3, 4, 5, 6, 7}
assert not red_set
assert indices == [0, 1, 2, 3, None, 4, None, None]
assert mat.lin_set == {0, 1, 2, 3, 4}
poly = cdd.polyhedron_from_matrix(mat)
v_rep = cdd.copy_output(poly)
assert not v_rep.array

0 comments on commit 72c1ceb

Please sign in to comment.