Fix version number
[linpy.git] / linpy / polyhedra.py
index 1ccbe9c..820b014 100644 (file)
@@ -94,15 +94,23 @@ class Polyhedron(Domain):
         sc_equalities = []
         if equalities is not None:
             for equality in equalities:
         sc_equalities = []
         if equalities is not None:
             for equality in equalities:
-                if not isinstance(equality, LinExpr):
-                    raise TypeError('equalities must be linear expressions')
-                sc_equalities.append(equality.scaleint())
+                if isinstance(equality, LinExpr):
+                    sc_equalities.append(equality.scaleint())
+                elif isinstance(equality, numbers.Rational):
+                    sc_equalities.append(Rational(equality).scaleint())
+                else:
+                    raise TypeError('equalities must be linear expressions '
+                        'or rational numbers')
         sc_inequalities = []
         if inequalities is not None:
             for inequality in inequalities:
         sc_inequalities = []
         if inequalities is not None:
             for inequality in inequalities:
-                if not isinstance(inequality, LinExpr):
-                    raise TypeError('inequalities must be linear expressions')
-                sc_inequalities.append(inequality.scaleint())
+                if isinstance(inequality, LinExpr):
+                    sc_inequalities.append(inequality.scaleint())
+                elif isinstance(inequality, numbers.Rational):
+                    sc_inequalities.append(Rational(inequality).scaleint())
+                else:
+                    raise TypeError('inequalities must be linear expressions '
+                        'or rational numbers')
         symbols = cls._xsymbols(sc_equalities + sc_inequalities)
         islbset = cls._toislbasicset(sc_equalities, sc_inequalities, symbols)
         return cls._fromislbasicset(islbset, symbols)
         symbols = cls._xsymbols(sc_equalities + sc_inequalities)
         islbset = cls._toislbasicset(sc_equalities, sc_inequalities, symbols)
         return cls._fromislbasicset(islbset, symbols)
@@ -214,6 +222,10 @@ class Polyhedron(Domain):
 
     @classmethod
     def _fromislbasicset(cls, islbset, symbols):
 
     @classmethod
     def _fromislbasicset(cls, islbset, symbols):
+        if bool(libisl.isl_basic_set_is_empty(islbset)):
+            return Empty
+        if bool(libisl.isl_basic_set_is_universe(islbset)):
+            return Universe
         islconstraints = islhelper.isl_basic_set_constraints(islbset)
         equalities = []
         inequalities = []
         islconstraints = islhelper.isl_basic_set_constraints(islbset)
         equalities = []
         inequalities = []