From aa1afe86bd8c0669635439c1773f6a28ab907def Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 11 May 2020 15:50:43 +0200 Subject: [PATCH] tuple -> generator --- src/sage/geometry/polyhedron/base.py | 50 +++++++++---------- .../combinatorial_polyhedron/base.pyx | 16 +++--- src/sage/geometry/polyhedron/library.py | 10 ++-- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 66a9c42d9af..1196816c1cf 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -1594,50 +1594,50 @@ def Hrepresentation_str(self, separator='\n', latex=False, style='>=', align=Non sage: P = polytopes.permutahedron(3) sage: print(P.Hrepresentation_str()) x0 + x1 + x2 == 6 - -x1 - x2 >= -5 - -x2 >= -3 - -x1 >= -3 + x0 + x1 >= 3 + -x0 - x1 >= -5 x1 >= 1 - x1 + x2 >= 3 - x2 >= 1 + -x0 >= -3 + x0 >= 1 + -x1 >= -3 sage: print(P.Hrepresentation_str(style='<=')) -x0 - x1 - x2 == -6 - x1 + x2 <= 5 - x2 <= 3 - x1 <= 3 + -x0 - x1 <= -3 + x0 + x1 <= 5 -x1 <= -1 - -x1 - x2 <= -3 - -x2 <= -1 + x0 <= 3 + -x0 <= -1 + x1 <= 3 sage: print(P.Hrepresentation_str(style='positive')) x0 + x1 + x2 == 6 - 5 >= x1 + x2 - 3 >= x2 - 3 >= x1 + x0 + x1 >= 3 + 5 >= x0 + x1 x1 >= 1 - x1 + x2 >= 3 - x2 >= 1 + 3 >= x0 + x0 >= 1 + 3 >= x1 sage: print(P.Hrepresentation_str(latex=True)) \begin{array}{rcl} x_{0} + x_{1} + x_{2} & = & 6 \\ - -x_{1} - x_{2} & \geq & -5 \\ - -x_{2} & \geq & -3 \\ - -x_{1} & \geq & -3 \\ + x_{0} + x_{1} & \geq & 3 \\ + -x_{0} - x_{1} & \geq & -5 \\ x_{1} & \geq & 1 \\ - x_{1} + x_{2} & \geq & 3 \\ - x_{2} & \geq & 1 + -x_{0} & \geq & -3 \\ + x_{0} & \geq & 1 \\ + -x_{1} & \geq & -3 \end{array} sage: print(P.Hrepresentation_str(align=False)) x0 + x1 + x2 == 6 - -x1 - x2 >= -5 - -x2 >= -3 - -x1 >= -3 + x0 + x1 >= 3 + -x0 - x1 >= -5 x1 >= 1 - x1 + x2 >= 3 - x2 >= 1 + -x0 >= -3 + x0 >= 1 + -x1 >= -3 sage: c = polytopes.cube() sage: c.Hrepresentation_str(separator=', ', style='positive') diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index 58dc0c23a21..0db2fd41dc8 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -687,12 +687,12 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C = CombinatorialPolyhedron(P) sage: C.Hrepresentation() (An equation (1, 1, 1) x - 6 == 0, - An inequality (0, -1, -1) x + 5 >= 0, - An inequality (0, 0, -1) x + 3 >= 0, - An inequality (0, -1, 0) x + 3 >= 0, + An inequality (1, 1, 0) x - 3 >= 0, + An inequality (-1, -1, 0) x + 5 >= 0, An inequality (0, 1, 0) x - 1 >= 0, - An inequality (0, 1, 1) x - 3 >= 0, - An inequality (0, 0, 1) x - 1 >= 0) + An inequality (-1, 0, 0) x + 3 >= 0, + An inequality (1, 0, 0) x - 1 >= 0, + An inequality (0, -1, 0) x + 3 >= 0) sage: points = [(1,0,0), (0,1,0), (0,0,1), ....: (-1,0,0), (0,-1,0), (0,0,-1)] @@ -1285,10 +1285,10 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.permutahedron(2) sage: C = CombinatorialPolyhedron(P) sage: C.ridges() - ((An inequality (0, -1) x + 2 >= 0, An inequality (0, 1) x - 1 >= 0),) + ((An inequality (1, 0) x - 1 >= 0, An inequality (-1, 0) x + 2 >= 0),) sage: C.ridges(add_equalities=True) - (((An inequality (0, -1) x + 2 >= 0, An equation (1, 1) x - 3 == 0), - (An inequality (0, 1) x - 1 >= 0, An equation (1, 1) x - 3 == 0)),) + (((An inequality (1, 0) x - 1 >= 0, An equation (1, 1) x - 3 == 0), + (An inequality (-1, 0) x + 2 >= 0, An equation (1, 1) x - 3 == 0)),) sage: P = polytopes.cyclic_polytope(4,5) sage: C = CombinatorialPolyhedron(P) diff --git a/src/sage/geometry/polyhedron/library.py b/src/sage/geometry/polyhedron/library.py index 2044842eee4..fa453f71f55 100644 --- a/src/sage/geometry/polyhedron/library.py +++ b/src/sage/geometry/polyhedron/library.py @@ -2535,7 +2535,7 @@ def permutahedron(self, n, project=False, backend=None): sage: assert P == Polyhedron(P.vertices()) sage: assert P == Polyhedron(ieqs=P.inequalities(), eqns=P.equations()) """ - verts = tuple(itertools.permutations(range(1, n + 1))) + verts = itertools.permutations(range(1, n + 1)) if project: verts = project_points(*verts) return Polyhedron(vertices=verts, backend=backend) @@ -2547,15 +2547,15 @@ def tri(m): # Each proper `S \subset [n]` corresponds exactly to # a facet that minimizes the coordinates in `S`. # The minimal sum for `m` coordinates is `(m*(m+1))/2`. - ieqs = tuple((-tri(sum(x)),) + x - for x in itertools.product([0,1], repeat=n) - if 0 < sum(x) < n) + ieqs = ((-tri(sum(x)),) + x + for x in itertools.product([0,1], repeat=n) + if 0 < sum(x) < n) # Adding the defining equality. eqns = ((-tri(n),) + tuple(1 for _ in range(n)),) return parent([verts, [], []], [ieqs, eqns], - Vrep_minimal=True, Hrep_minimal=True) + Vrep_minimal=True, Hrep_minimal=True, pref_rep="Hrep") def generalized_permutahedron(self, coxeter_type, point=None, exact=True, regular=False, backend=None):