From 72c1ceba5235ba1a666070f8cc051df5c80187a2 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Mon, 13 Jan 2025 09:07:26 +0000 Subject: [PATCH] Add tests for issue #80. --- test/gmp/test_issue80.py | 26 ++++++++++++++++++++++++++ test/test_issue80.py | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/gmp/test_issue80.py create mode 100644 test/test_issue80.py diff --git a/test/gmp/test_issue80.py b/test/gmp/test_issue80.py new file mode 100644 index 0000000..454a2b5 --- /dev/null +++ b/test/gmp/test_issue80.py @@ -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 diff --git a/test/test_issue80.py b/test/test_issue80.py new file mode 100644 index 0000000..607653f --- /dev/null +++ b/test/test_issue80.py @@ -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