#24837 closed enhancement (fixed)
Improve the output of repr_pretty_Hrepresentation for Polyhedron
Reported by:  jipilab  Owned by:  

Priority:  major  Milestone:  sage8.4 
Component:  geometry  Keywords:  days93, IMAPolyGeom 
Cc:  vdelecroix, moritz, tscrim  Merged in:  
Authors:  JeanPhilippe Labbé  Reviewers:  Moritz Firsching, Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  b1ae583 (Commits, GitHub, GitLab)  Commit:  
Dependencies:  #22572  Stopgaps: 
Description (last modified by )
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 Hrelations:
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
.
Change History (24)
comment:1 Changed 3 years ago by
 Branch set to u/jipilab/24837
 Commit set to 7cf1a562e411bb1307b906c173d04f177d66fc0f
 Dependencies set to #22572
 Description modified (diff)
 Status changed from new to needs_review
comment:2 Changed 3 years ago by
 Description modified (diff)
comment:3 Changed 3 years ago by
 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
 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
 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:6 Changed 3 years ago by
 Keywords IMAPolyGeom added
comment:7 Changed 3 years ago by
 Branch changed from u/jipilab/24837 to u/moritz/24837
comment:8 Changed 3 years ago by
 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
 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
 Milestone changed from sage8.2 to sage8.3
comment:12 Changed 3 years ago by
 Branch changed from u/moritz/24837 to u/jipilab/24837
 Commit changed from f98b24a1e9ae874ce7f4a4a0b8d086619132d328 to e6ba9cc64d2fe33381bfdf4e0b1ca7c4802b9531
 Status changed from needs_work to needs_review
comment:13 Changed 3 years ago by
Ping!
comment:14 Changed 3 years ago by
 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 warnlong 49.3 src/doc/en/thematic_tutorials/geometry/tips.rst # 2 doctests failed
comment:15 Changed 3 years ago by
 Commit changed from e6ba9cc64d2fe33381bfdf4e0b1ca7c4802b9531 to 736f60f40460584e93c64a2b5bc30ae133800fe2
Branch pushed to git repo; I updated commit sha1. New commits:
736f60f  fixed doctests

comment:17 followup: ↓ 18 Changed 3 years ago by
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 ; followup: ↓ 19 Changed 3 years ago by
 Cc tscrim added
Replying to jipilab:
There are two pyflakes warnings about the usage of
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
Replying to tscrim:
Replying to jipilab:
There are two pyflakes warnings about the usage of
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
 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
 Status changed from needs_review to positive_review
Done! Thanks for the review!
comment:22 Changed 3 years ago by
 Milestone changed from sage8.3 to sage8.4
update milestone 8.3 > 8.4
comment:23 Changed 3 years ago by
 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
 Commit b1ae58333b87efe5574bf876c6d53cddd3f8420d deleted
There is a followup ticket #26141 concerning the code quality.
Once the tutorial is merged in #22572, we should change the "tips" page accordingly...
New commits:
first version