Simplify BasicSet.__str__
[linpy.git] / pypol / linear.py
index 348294c..8e96f35 100644 (file)
@@ -4,8 +4,8 @@ import numbers
 
 from fractions import Fraction, gcd
 
 
 from fractions import Fraction, gcd
 
-from . import isl, islhelper
-from .isl import libisl, Context, BasicSet
+from . import isl
+from .isl import libisl
 
 
 __all__ = [
 
 
 __all__ = [
@@ -42,6 +42,9 @@ def _polymorphic_operator(func):
     return wrapper
 
 
     return wrapper
 
 
+_main_ctx = isl.Context()
+
+
 class Expression:
     """
     This class implements linear expressions.
 class Expression:
     """
     This class implements linear expressions.
@@ -498,8 +501,7 @@ class Polyhedron:
         if symbols is None:
             symbols = self.symbols()
         num_coefficients = len(symbols)
         if symbols is None:
             symbols = self.symbols()
         num_coefficients = len(symbols)
-        ctx = Context()
-        space = libisl.isl_space_set_alloc(ctx, 0, num_coefficients)
+        space = libisl.isl_space_set_alloc(_main_ctx, 0, num_coefficients)
         bset = libisl.isl_basic_set_universe(libisl.isl_space_copy(space))
         ls = libisl.isl_local_space_from_space(space)
         ceq = libisl.isl_equality_alloc(libisl.isl_local_space_copy(ls))
         bset = libisl.isl_basic_set_universe(libisl.isl_space_copy(space))
         ls = libisl.isl_local_space_from_space(space)
         ceq = libisl.isl_equality_alloc(libisl.isl_local_space_copy(ls))
@@ -514,7 +516,7 @@ class Polyhedron:
                 for eq in coeff_eq:
                     num = coeff_eq.get(eq)
                     iden = symbols.index(eq)
                 for eq in coeff_eq:
                     num = coeff_eq.get(eq)
                     iden = symbols.index(eq)
-                    ceq = libisl.isl_constraint_set_coefficient_si(ceq, islhelper.isl_dim_set, iden, num)  #use 3 for type isl_dim_set
+                    ceq = libisl.isl_constraint_set_coefficient_si(ceq, libisl.isl_dim_set, iden, num)  #use 3 for type isl_dim_set
             bset = libisl.isl_basic_set_add_constraint(bset, ceq)
         if list(self.inequalities): #check if any inequalities exist
             for ineq in self.inequalities:
             bset = libisl.isl_basic_set_add_constraint(bset, ceq)
         if list(self.inequalities): #check if any inequalities exist
             for ineq in self.inequalities:
@@ -525,9 +527,9 @@ class Polyhedron:
                 for ineq in coeff_in:
                     num = coeff_in.get(ineq)
                     iden = symbols.index(ineq)
                 for ineq in coeff_in:
                     num = coeff_in.get(ineq)
                     iden = symbols.index(ineq)
-                    cin = libisl.isl_constraint_set_coefficient_si(cin, islhelper.isl_dim_set, iden, num)  #use 3 for type isl_dim_set
+                    cin = libisl.isl_constraint_set_coefficient_si(cin, libisl.isl_dim_set, iden, num)  #use 3 for type isl_dim_set
             bset = libisl.isl_basic_set_add_constraint(bset, cin)
             bset = libisl.isl_basic_set_add_constraint(bset, cin)
-        bset = BasicSet(bset)
+        bset = isl.BasicSet(bset)
         return bset
 
     def from_isl(self, bset):
         return bset
 
     def from_isl(self, bset):