Add basic tests for drop_dims
authorDanielle Bolan <n02702451@hawkmail.newpaltz.edu>
Tue, 1 Jul 2014 14:22:41 +0000 (16:22 +0200)
committerDanielle Bolan <n02702451@hawkmail.newpaltz.edu>
Tue, 1 Jul 2014 14:22:41 +0000 (16:22 +0200)
examples/squares.py
pypol/tests/test_domains.py

index d23e63694022baf80e9d1dc5df5084510bcc43cd..e140e30bf3b767b562556622da7e6cb27747cf5a 100755 (executable)
@@ -63,5 +63,7 @@ print()
 print('sq6:', sq6)
 print('sq6 simplified:', sq6.sample())
 print()
-print('sq7 with out constraints involving y and a', sq7.drop_dims('y a'))
+#print(u.drop_dims(' '))
+print('sq7 with out constraints involving y and a', sq7.drop_dims('y a')) #drops dims that are passed
+
 
index 555c3313201213ca64f460128cf843ec8aef99cc..1beaa85e7c9154b9d1bea7611c03c24669a8dc8f 100644 (file)
@@ -21,6 +21,7 @@ class TestDomain(unittest.TestCase):
         self.disjoint = And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0))
         self.compliment = Or(Ge(-x - 1, 0), Ge(x - 3, 0), And(Ge(x, 0), Ge(-x + 2, 0), Ge(-y - 1, 0)), And(Ge(x, 0), Ge(-x + 2, 0), Ge(y - 3, 0)))
         self.hull = And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0))
+        self.dropped = And(Ge(y, 0), Ge(-y + 2, 0))
         self.sample = And(Eq(y - 3, 0), Eq(x - 1, 0))
         self.intersection = And(Ge(x - 1, 0), Ge(-x + 2, 0), Ge(y - 1, 0), Ge(-y + 2, 0))
         self.union = Or(And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0)), And(Ge(x - 1, 0), Ge(-x + 3, 0), Ge(y - 1, 0), Ge(-y + 3, 0)))
@@ -75,6 +76,12 @@ class TestDomain(unittest.TestCase):
 
     def test_polyhedral_hull(self):
         self.assertEqual(self.square1.polyhedral_hull(), self.hull)
+    
+    def test_drop_dims(self):
+        self.assertEqual(self.square1.drop_dims('x'), self.dropped)
+        self.assertEqual(self.square1.drop_dims('x y'), self.universe)
+        self.assertEqual(self.universe.drop_dims(' '), self.universe)
+        self.assertEqual(self.empty.drop_dims(' '), Empty)
 
     @unittest.expectedFailure
     def test_simplify(self):