Change string representations of Expression and Polyhedron
[linpy.git] / pypol / linear.py
index 74b5477..b40415f 100644 (file)
@@ -285,13 +285,7 @@ class Expression:
             return '({})'.format(string)
 
     def __repr__(self):
             return '({})'.format(string)
 
     def __repr__(self):
-        string = '{}({{'.format(self.__class__.__name__)
-        for i, (symbol, coefficient) in enumerate(self.coefficients()):
-            if i != 0:
-                string += ', '
-            string += '{!r}: {!r}'.format(symbol, coefficient)
-        string += '}}, {!r})'.format(self.constant)
-        return string
+        return '{}({!r})'.format(self.__class__.__name__, str(self))
 
     @_polymorphic_method
     def __eq__(self, other):
 
     @_polymorphic_method
     def __eq__(self, other):
@@ -673,7 +667,7 @@ class Polyhedron:
             constraints.append('{} == 0'.format(constraint))
         for constraint in self.inequalities:
             constraints.append('{} >= 0'.format(constraint))
             constraints.append('{} == 0'.format(constraint))
         for constraint in self.inequalities:
             constraints.append('{} >= 0'.format(constraint))
-        return '{{{}}}'.format(', '.join(constraints))
+        return '{}'.format(', '.join(constraints))
 
     def __repr__(self):
         if self.isempty():
 
     def __repr__(self):
         if self.isempty():
@@ -681,10 +675,7 @@ class Polyhedron:
         elif self.isuniverse():
             return 'Universe'
         else:
         elif self.isuniverse():
             return 'Universe'
         else:
-            equalities = list(self.equalities)
-            inequalities = list(self.inequalities)
-            return '{}(equalities={!r}, inequalities={!r})' \
-                    ''.format(self.__class__.__name__, equalities, inequalities)
+            return '{}({!r})'.format(self.__class__.__name__, str(self))
 
     @classmethod
     def _fromsympy(cls, expr):
 
     @classmethod
     def _fromsympy(cls, expr):