Sage: Ticket #10336: Cannot plot non-strictly convex cones
https://trac.sagemath.org/ticket/10336
<p>
Plotting cones relies on the cone's face lattice:
</p>
<pre class="wiki">sage: halfspace = Cone([(1,0,0), (0,1,0), (-1,-1,0), (0,0,1)])
sage: halfspace.plot()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/home/vbraun/opt/sage-4.6/devel/sage-main/<ipython console> in <module>()
/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/cone.pyc in plot(self, **options)
2623 if self.dim() >= 2:
2624 # Modify wall labels to match the ambient cone or fan too.
-> 2625 walls = self.faces(2)
2626 try:
2627 ambient_walls = self.ambient().faces(2)
/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/cone.pyc in faces(self, dim, codim)
2015 if "_faces" not in self.__dict__:
2016 self._faces = tuple(self._sort_faces(e.element for e in level)
-> 2017 for level in self.face_lattice().level_sets())
2018 # To avoid duplication and ensure order consistency
2019 if self.dim() > 0:
/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/cone.pyc in face_lattice(self)
1854 # We need to compute face lattice on our own
1855 if not self.is_strictly_convex():
-> 1856 raise NotImplementedError("face lattice is currently "
1857 "implemented only for strictly convex cones!")
1858 def ConeFace(rays, facets):
NotImplementedError: face lattice is currently implemented only for strictly convex cones!
</pre><p>
Is there any reason for why we can't compute the face lattice of a non-strictly convex cone? If there is, we might want to still plot something reasonable in that case...
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/10336
Trac 1.1.6novoseltFri, 26 Nov 2010 18:58:12 GMTowner, type changed
https://trac.sagemath.org/ticket/10336#comment:1
https://trac.sagemath.org/ticket/10336#comment:1
<ul>
<li><strong>owner</strong>
changed from <em>AlexGhitza</em> to <em>novoselt</em>
</li>
<li><strong>type</strong>
changed from <em>defect</em> to <em>enhancement</em>
</li>
</ul>
<p>
Originally there was no code to compute face lattices of non-strictly convex cones, but with your recent modifications it will be easy to fix.
</p>
<p>
Plotting code that I wrote will not immediately work for such cases anyway, but again it should not be terribly difficult to fix, I just was more concerned with plotting fans.
</p>
<p>
Will work on it!
</p>
<p>
P.S. Since it was due to <code>NotImplemented</code>, I consider this ticket an enhancement ;-)
</p>
TicketnovoseltFri, 26 Nov 2010 22:53:38 GMT
https://trac.sagemath.org/ticket/10336#comment:2
https://trac.sagemath.org/ticket/10336#comment:2
<p>
I am thinking of:
</p>
<ul><li>allowing <code>cone.faces(d)</code> to accept any d and return an empty tuple if there are no faces of dimension d;
</li><li>returning a tuple of non-empty tuples as the output of <code>cone.faces()</code>, i.e. for a half-space it will be just <code>((plane,), (half-space,))</code> instead of <code>((), (), (plane,), (half-space,))</code> where the d-th tuple contains faces of dimension d.
</li></ul><p>
Thoughts?
</p>
TicketnovoseltFri, 26 Nov 2010 22:59:22 GMTstatus changed; work_issues set
https://trac.sagemath.org/ticket/10336#comment:3
https://trac.sagemath.org/ticket/10336#comment:3
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_work</em>
</li>
<li><strong>work_issues</strong>
set to <em>fix faces and add plotting</em>
</li>
</ul>
<p>
I attached the first development version. <code>face_lattice</code> should work for any cone now and there are a few small corrections in other places. Definitely needs more work!-)
</p>
TicketvbraunFri, 26 Nov 2010 23:55:00 GMT
https://trac.sagemath.org/ticket/10336#comment:4
https://trac.sagemath.org/ticket/10336#comment:4
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/10336#comment:2" title="Comment 2">novoselt</a>:
</p>
<blockquote class="citation">
<p>
I am thinking of:
</p>
<ul><li>allowing <code>cone.faces(d)</code> to accept any d and return an empty tuple if there are no faces of dimension d;
</li><li>returning a tuple of non-empty tuples as the output of <code>cone.faces()</code>
</li></ul></blockquote>
<p>
both sound good to me!
</p>
TicketnovoseltSat, 27 Nov 2010 02:49:23 GMTwork_issues, milestone changed
https://trac.sagemath.org/ticket/10336#comment:5
https://trac.sagemath.org/ticket/10336#comment:5
<ul>
<li><strong>work_issues</strong>
changed from <em>fix faces and add plotting</em> to <em>add plotting</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-5.0</em> to <em>sage-4.6.2</em>
</li>
</ul>
<p>
Great! Done! Refreshed patch should deal fine with faces in all cases, all old doctests pass and I added a couple for non-strictly convex cones - there was an issue originally for "totally non-strictly conex" cones like a plane, that's why there is <code>DiGraph(1)</code> in <code>Hasse_diagram</code>.
</p>
<p>
Regarding the plots. Let's take, e.g. a half-plane generated by vectors (1,0), (1,1), (0,1), (-1,0). I propose that its plot will look exactly like the plot of the fan with these generators except that two middle vectors will be plotted as generators, but there will be no rays in their direction extending to the boundary of the plot (labels still will be places on the boundary out of colored regions). The label for the half-plane itself will be randomly placed between two consecutive generators - this way it will be inside and will not get crossed by one of the internal generators.
</p>
TicketnovoseltSat, 27 Nov 2010 05:42:27 GMTwork_issues changed
https://trac.sagemath.org/ticket/10336#comment:6
https://trac.sagemath.org/ticket/10336#comment:6
<ul>
<li><strong>work_issues</strong>
changed from <em>add plotting</em> to <em>wall labels positioning and round mode</em>
</li>
</ul>
<p>
OK, it remains to make the default "round" mode work and reposition labels of non-strictly convex 2-d walls.
</p>
TicketnovoseltSun, 28 Nov 2010 18:08:04 GMTstatus changed; author set; work_issues deleted
https://trac.sagemath.org/ticket/10336#comment:7
https://trac.sagemath.org/ticket/10336#comment:7
<ul>
<li><strong>status</strong>
changed from <em>needs_work</em> to <em>needs_review</em>
</li>
<li><strong>work_issues</strong>
<em>wall labels positioning and round mode</em> deleted
</li>
<li><strong>author</strong>
set to <em>Andrey Novoseltsev</em>
</li>
</ul>
<p>
Now plotting should work in all modes.
</p>
<p>
Wall labels will be positioned between two generators that generate the plane of the wall. This will result in OK placement for automatically adjusted generators (i.e. when half-planes are generated by 3 rays and planes by 4). If the user has forced (via <code>check=False</code> option) other generators, they can potentially cross labels, in which case this user should place labels manually.
</p>
<p>
I have switched <code>toric_plotter</code> to using <code>RDF</code> instead of <code>RR</code> since the first seems to be a little faster.
</p>
TicketnovoseltSun, 28 Nov 2010 20:17:42 GMTattachment set
https://trac.sagemath.org/ticket/10336
https://trac.sagemath.org/ticket/10336
<ul>
<li><strong>attachment</strong>
set to <em>trac_10336_plot_non_strictly_convex_cones.patch</em>
</li>
</ul>
TicketnovoseltSun, 28 Nov 2010 20:24:26 GMT
https://trac.sagemath.org/ticket/10336#comment:8
https://trac.sagemath.org/ticket/10336#comment:8
<p>
Made user's <code>radius</code> more important (new code block in <code>ToricPlotter.__init__</code>), so that it is possible to make it small even if it cuts off some generators.
</p>
TicketnovoseltSun, 05 Dec 2010 19:09:35 GMT
https://trac.sagemath.org/ticket/10336#comment:9
https://trac.sagemath.org/ticket/10336#comment:9
<p>
Depends on <a class="closed ticket" href="https://trac.sagemath.org/ticket/9972" title="enhancement: Add fan morphisms (closed: fixed)">#9972</a>.
</p>
TicketvbraunMon, 20 Dec 2010 12:34:11 GMTstatus changed; reviewer set
https://trac.sagemath.org/ticket/10336#comment:10
https://trac.sagemath.org/ticket/10336#comment:10
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
<li><strong>reviewer</strong>
set to <em>Volker Braun</em>
</li>
</ul>
<p>
Nice! Tested against sage-4.6.1alpha3
</p>
TicketjdemeyerTue, 25 Jan 2011 08:15:25 GMTstatus changed; resolution, merged set
https://trac.sagemath.org/ticket/10336#comment:11
https://trac.sagemath.org/ticket/10336#comment:11
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>merged</strong>
set to <em>sage-4.6.2.alpha2</em>
</li>
</ul>
Ticket