Rename Expression class into LinExpr
[linpy.git] / linpy / polyhedra.py
index 8eddb2d..346ffff 100644 (file)
@@ -23,7 +23,7 @@ from . import islhelper
 
 from .islhelper import mainctx, libisl
 from .geometry import GeometricObject, Point
 
 from .islhelper import mainctx, libisl
 from .geometry import GeometricObject, Point
-from .linexprs import Expression, Rational
+from .linexprs import LinExpr, Rational
 from .domains import Domain
 
 
 from .domains import Domain
 
 
@@ -50,7 +50,7 @@ class Polyhedron(Domain):
         """
         Create and return a new Polyhedron from a string or list of equalities and inequalities.
         """
         """
         Create and return a new Polyhedron from a string or list of equalities and inequalities.
         """
-        
+
         if isinstance(equalities, str):
             if inequalities is not None:
                 raise TypeError('too many arguments')
         if isinstance(equalities, str):
             if inequalities is not None:
                 raise TypeError('too many arguments')
@@ -63,14 +63,14 @@ class Polyhedron(Domain):
             equalities = []
         else:
             for i, equality in enumerate(equalities):
             equalities = []
         else:
             for i, equality in enumerate(equalities):
-                if not isinstance(equality, Expression):
+                if not isinstance(equality, LinExpr):
                     raise TypeError('equalities must be linear expressions')
                 equalities[i] = equality.scaleint()
         if inequalities is None:
             inequalities = []
         else:
             for i, inequality in enumerate(inequalities):
                     raise TypeError('equalities must be linear expressions')
                 equalities[i] = equality.scaleint()
         if inequalities is None:
             inequalities = []
         else:
             for i, inequality in enumerate(inequalities):
-                if not isinstance(inequality, Expression):
+                if not isinstance(inequality, LinExpr):
                     raise TypeError('inequalities must be linear expressions')
                 inequalities[i] = inequality.scaleint()
         symbols = cls._xsymbols(equalities + inequalities)
                     raise TypeError('inequalities must be linear expressions')
                 inequalities[i] = inequality.scaleint()
         symbols = cls._xsymbols(equalities + inequalities)
@@ -191,7 +191,7 @@ class Polyhedron(Domain):
                 coefficient = islhelper.isl_val_to_int(coefficient)
                 if coefficient != 0:
                     coefficients[symbol] = coefficient
                 coefficient = islhelper.isl_val_to_int(coefficient)
                 if coefficient != 0:
                     coefficients[symbol] = coefficient
-            expression = Expression(coefficients, constant)
+            expression = LinExpr(coefficients, constant)
             if libisl.isl_constraint_is_equality(islconstraint):
                 equalities.append(expression)
             else:
             if libisl.isl_constraint_is_equality(islconstraint):
                 equalities.append(expression)
             else:
@@ -345,13 +345,13 @@ Universe = UniverseType()
 def _polymorphic(func):
     @functools.wraps(func)
     def wrapper(left, right):
 def _polymorphic(func):
     @functools.wraps(func)
     def wrapper(left, right):
-        if not isinstance(left, Expression):
+        if not isinstance(left, LinExpr):
             if isinstance(left, numbers.Rational):
                 left = Rational(left)
             else:
                 raise TypeError('left must be a a rational number '
                     'or a linear expression')
             if isinstance(left, numbers.Rational):
                 left = Rational(left)
             else:
                 raise TypeError('left must be a a rational number '
                     'or a linear expression')
-        if not isinstance(right, Expression):
+        if not isinstance(right, LinExpr):
             if isinstance(right, numbers.Rational):
                 right = Rational(right)
             else:
             if isinstance(right, numbers.Rational):
                 right = Rational(right)
             else: