Opened 3 years ago

Closed 3 years ago

# Improve the output of repr_pretty_Hrepresentation for Polyhedron

Reported by: Owned by: jipilab major sage-8.4 geometry days93, IMA-PolyGeom vdelecroix, moritz, tscrim Jean-Philippe Labbé Moritz Firsching, Travis Scrimshaw N/A b1ae583 #22572

Following #22572, we can improve the output of the pretty print:

    sage: Cube = polytopes.cube()
sage: TCube = Cube.truncation()
sage: Nice_repr = TCube.repr_pretty_Hrepresentation(separator='\n')
sage: print(Nice_repr)
1 >= x0
1 >= x1
3*x1 + 7 >= 3*x0 + 3*x2
x0 + 1 >= 0
x1 + 1 >= 0
3*x0 + 7 >= 3*x1 + 3*x2
3*x0 + 3*x1 + 7 >= 3*x2
3*x0 + 3*x2 + 7 >= 3*x1
3*x0 + 3*x1 + 3*x2 + 7 >= 0
x2 + 1 >= 0
1 >= x2
3*x1 + 3*x2 + 7 >= 3*x0
3*x2 + 7 >= 3*x0 + 3*x1
7 >= 3*x0 + 3*x1 + 3*x2


In the new version it gives:

    sage: print(TCube.Hrepresentation_str())
-x0 >= -1
-x1 >= -1
-3*x0 + 3*x1 - 3*x2 >= -7
x0 >= -1
x1 >= -1
3*x0 - 3*x1 - 3*x2 >= -7
3*x0 + 3*x1 - 3*x2 >= -7
3*x0 - 3*x1 + 3*x2 >= -7
3*x0 + 3*x1 + 3*x2 >= -7
x2 >= -1
-x2 >= -1
-3*x0 + 3*x1 + 3*x2 >= -7
-3*x0 - 3*x1 + 3*x2 >= -7
-3*x0 - 3*x1 - 3*x2 >= -7

sage: print(TCube.Hrepresentation_str(latex=True))
\begin{array}{rcl}
-x_{0} & \geq & -1 \\
-x_{1} & \geq & -1 \\
-3 \, x_{0} + 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
x_{0} & \geq & -1 \\
x_{1} & \geq & -1 \\
3 \, x_{0} - 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} + 3 \, x_{1} - 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} - 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
3 \, x_{0} + 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
x_{2} & \geq & -1 \\
-x_{2} & \geq & -1 \\
-3 \, x_{0} + 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
-3 \, x_{0} - 3 \, x_{1} + 3 \, x_{2} & \geq & -7 \\
-3 \, x_{0} - 3 \, x_{1} - 3 \, x_{2} & \geq & -7
\end{array}


The style parameter allows to change the way to print the H-relations:

sage: P = polytopes.permutahedron(3)
sage: print(P.Hrepresentation_str(style='<='))
-x0 - x1 - x2 == -6
x1 + x2 <=  5
x2 <=  3
x1 <=  3
-x1 <= -1
-x1 - x2 <= -3
-x2 <= -1
sage: print(P.Hrepresentation_str(style='positive'))
x0 + x1 + x2 == 6
5 >= x1 + x2
3 >= x2
3 >= x1
x1 >= 1
x1 + x2 >= 3
x2 >= 1


In order to make the function more apparent, deprecation of the current function is perhaps a good idea and change the name to Hrepresentation_str.

### comment:1 Changed 3 years ago by jipilab

• Authors set to Jean-Philippe Labbé
• Branch set to u/jipilab/24837
• Commit set to 7cf1a562e411bb1307b906c173d04f177d66fc0f
• Dependencies set to #22572
• Description modified (diff)
• Status changed from new to needs_review

Once the tutorial is merged in #22572, we should change the "tips" page accordingly...

New commits:

 ​7cf1a56 first version

### comment:2 Changed 3 years ago by jipilab

• Description modified (diff)

### comment:3 Changed 3 years ago by jipilab

• Summary changed from Improve the output of repr_pretty for Polyhedron to Improve the output of repr_pretty_Hrepresentation for Polyhedron

### comment:4 Changed 3 years ago by git

• Commit changed from 7cf1a562e411bb1307b906c173d04f177d66fc0f to 132c27af3c97ad7892cfdc2242259802175cdc0d

Branch pushed to git repo; I updated commit sha1. New commits:

 ​132c27a Merge branch 'develop' into 24837

### comment:5 Changed 3 years ago by git

• Commit changed from 132c27af3c97ad7892cfdc2242259802175cdc0d to 3fea478c2c433fa7976f8ba1fda76684850b511f

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

 ​231cd56 deleted trailing whitespace ​f685c64 fixed some typos in lectures.rst ​7f5e125 fixed typos in polyhedra_quickref.rst ​bd6c356 LateX -> LaTeX in polytope_tikz.rst ​b1ce45b Several other corrections ​d526f70 renamed tutorial files ​d7896f8 Merge branch 'develop' into 22572 ​597b802 Merge branch sage8.2.rc1 into 22572 ​066c7a5 Merge branch tutorial into 24837 ​3fea478 Adapted tutorial

### comment:7 Changed 3 years ago by moritz

• Branch changed from u/jipilab/24837 to u/moritz/24837

### comment:8 Changed 3 years ago by moritz

• Commit changed from 3fea478c2c433fa7976f8ba1fda76684850b511f to f98b24a1e9ae874ce7f4a4a0b8d086619132d328
• Reviewers set to Moritz Firsching

There was one doctest failing and a bit whitespace left. Other than that I think this is good to go. Set it on positive review on my behalf if you agree!

New commits:

 ​f98b24a fix a doctest and remove trailing whitespace

### comment:9 Changed 3 years ago by jipilab

• Status changed from needs_review to positive_review

The last bot test looks good. I'm setting it to positive review.

### comment:10 Changed 3 years ago by jipilab

• Milestone changed from sage-8.2 to sage-8.3

### comment:11 Changed 3 years ago by vbraun

• Status changed from positive_review to needs_work

Merge conflict

### comment:12 Changed 3 years ago by jipilab

• Branch changed from u/moritz/24837 to u/jipilab/24837
• Commit changed from f98b24a1e9ae874ce7f4a4a0b8d086619132d328 to e6ba9cc64d2fe33381bfdf4e0b1ca7c4802b9531
• Status changed from needs_work to needs_review

Solved the conflicts with Sage8.3.b1.

New commits:

 ​e6ba9cc Merged with Sage 8.3.b1

Ping!

### comment:14 Changed 3 years ago by tscrim

• Reviewers changed from Moritz Firsching to Moritz Firsching, Travis Scrimshaw
• Status changed from needs_review to needs_work

Two trivial failures; see patchbot for details:

sage -t --long --warn-long 49.3 src/doc/en/thematic_tutorials/geometry/tips.rst  # 2 doctests failed


### comment:15 Changed 3 years ago by git

• Commit changed from e6ba9cc64d2fe33381bfdf4e0b1ca7c4802b9531 to 736f60f40460584e93c64a2b5bc30ae133800fe2

Branch pushed to git repo; I updated commit sha1. New commits:

 ​736f60f fixed doctests

### comment:16 Changed 3 years ago by jipilab

• Status changed from needs_work to needs_review

Should now work...

### comment:17 follow-up: ↓ 18 Changed 3 years ago by jipilab

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

### comment:18 in reply to: ↑ 17 ; follow-up: ↓ 19 Changed 3 years ago by tscrim

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

Please do. What is imported in a file and what used in doctests, which is the global namespace, are essentially independent. Once you remove them, you can set a positive review on my behalf.

### comment:19 in reply to: ↑ 18 Changed 3 years ago by jipilab

There are two pyflakes warnings about the usage of QQ and RDF.

Question: if they are used in doctests, that's not necessary to import them, correct?

If so, I'd just remove them...

Please do. What is imported in a file and what used in doctests, which is the global namespace, are essentially independent. Once you remove them, you can set a positive review on my behalf.

Sounds good! I just wanted to make sure...

### comment:20 Changed 3 years ago by git

• Commit changed from 736f60f40460584e93c64a2b5bc30ae133800fe2 to b1ae58333b87efe5574bf876c6d53cddd3f8420d

Branch pushed to git repo; I updated commit sha1. New commits:

 ​b1ae583 Removed unnecessary import

### comment:21 Changed 3 years ago by jipilab

• Status changed from needs_review to positive_review

Done! Thanks for the review!

### comment:22 Changed 3 years ago by vdelecroix

• Milestone changed from sage-8.3 to sage-8.4

update milestone 8.3 -> 8.4

### comment:23 Changed 3 years ago by vbraun

• Branch changed from u/jipilab/24837 to b1ae58333b87efe5574bf876c6d53cddd3f8420d
• Resolution set to fixed
• Status changed from positive_review to closed

### comment:24 Changed 3 years ago by dkrenn

• Commit b1ae58333b87efe5574bf876c6d53cddd3f8420d deleted

There is a follow-up ticket #26141 concerning the code quality.

Note: See TracTickets for help on using tickets.