Ticket #5465 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[with patch, positive review] render3d for groebner fans is totally broken

Reported by: was Owned by: mhampton
Priority: major Milestone: sage-3.4.1
Component: geometry Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

teragon:~ wstein$ sage
----------------------------------------------------------------------
| Sage Version 3.4.alpha0, Release Date: 2009-02-24                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
sage: sage.rings.ideal.Katsura(P,3).groebner_fan().render3d()
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)

/Users/wstein/.sage/temp/teragon.local/68617/_Users_wstein__sage_init_sage_0.py in <module>()

/Users/wstein/build/sage-3.4.alpha0/local/lib/python2.5/site-packages/sage/rings/polynomial/groebner_fan.pyc in render3d(self, verbose)
   1067         g_cones_ieqs = [self._cone_to_ieq(q) for q in g_cones_facets]
   1068         # Now the cones are intersected with a plane:
-> 1069         cone_info = [ieq_to_vert(q,linearities=[[1,-1,-1,-1,-1]]) for q in g_cones_ieqs]
   1070 	if verbose:
   1071 	    for x in cone_info:

/Users/wstein/build/sage-3.4.alpha0/local/lib/python2.5/site-packages/sage/geometry/polyhedra.pyc in ieq_to_vert(in_list, linearities, cdd_type, verbose)
   1268             adj_index = index
   1269     # read the vertices and rays:
-> 1270     for index in range(vert_index,len(ans_lines)):
   1271         a_line = ans_lines[index]
   1272         if a_line.find('end') != -1: break

UnboundLocalError: local variable 'vert_index' referenced before assignment

Attachments

trac_5465_1.patch Download (2.6 KB) - added by mhampton 4 years ago.
Adds some more informative error messages

Change History

comment:1 Changed 4 years ago by mabshoff

  • Milestone changed from sage-3.4 to sage-3.4.1

comment:2 Changed 4 years ago by mhampton

This needs to have a better error message - the example here is trying to render a 2D fan with render3d, which doesn't make sense. So the code should check the dimension first, which I will do this week (I am currently traveling until Tuesday which makes development a bit harder). -Marshall

Changed 4 years ago by mhampton

Adds some more informative error messages

comment:3 Changed 4 years ago by mhampton

  • Summary changed from render3d for groebner fans is totally broken to [with patch, needs review] render3d for groebner fans is totally broken

comment:4 Changed 4 years ago by mvngu

  • Summary changed from [with patch, needs review] render3d for groebner fans is totally broken to [with patch, positive review] render3d for groebner fans is totally broken

REFEREE REPORT

The patch trac_5465_1.patch applies OK against Sage 3.4, all doctests pass with the -long option as well. Since the purpose of the patch is to add more meaningful error messages, I tried to get those two more meaningful messages. First, for the case where the number of generators is < 3:

sage: # first for the case of S.ngens() < 3...
sage: R.<x,y> = PolynomialRing(QQ,2)
sage: G = R.ideal([y^3 - x^2, y^2 - 13*x]).groebner_fan()
sage: G.render()
For 2-D fan rendering the polynomial ring must have 3 variables (or more, which are ignored).
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (118, 0))

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/16843/_home_mvngu__sage_init_sage_0.py in <module>()

/home/mvngu/scratch/sage-3.4/local/lib/python2.5/site-packages/sage/rings/polynomial/groebner_fan.pyc in render(self, file, larger, shift, rgbcolor, polyfill, scale_colors)
    902         if S.ngens() < 3:
    903             print "For 2-D fan rendering the polynomial ring must have 3 variables (or more, which are ignored)."
--> 904             raise NotImplementedError
    905         cmd = 'render'
    906         if shift:

NotImplementedError:

Yep, the error message is certainly now more comprehensible than something like UnboundLocalError which misses the main point that the number of generators is not of the required size. Now, for the case where the number of generators is not 4:

sage: # second, for the case of S.ngens() != 4...
sage: P.<a,b,c> = PolynomialRing(QQ, 3, order="lex")
sage: sage.rings.ideal.Katsura(P,3).groebner_fan().render3d()
For 3-D fan rendering the polynomial ring must have 4 variables
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/16843/_home_mvngu__sage_init_sage_0.py in <module>()

/home/mvngu/scratch/sage-3.4/local/lib/python2.5/site-packages/sage/rings/polynomial/groebner_fan.pyc in render3d(self, verbose)
   1070         if S.ngens() != 4:
   1071             print "For 3-D fan rendering the polynomial ring must have 4 variables"
-> 1072             raise NotImplementedError
   1073         g_cones = [q.groebner_cone() for q in self.reduced_groebner_bases()]
   1074         g_cones_facets = [q.facets() for q in g_cones]

NotImplementedError:

Again, I see a NotImplementedError which is certainly more comprehensible than the error message reported above by William Stein. And finally, given the correct number of generators, we have a nice Groebner fan :-) Positive review for the problem that the patch fixes.

comment:5 Changed 4 years ago by mabshoff

Well, to be absolutely pedantic: Shouldn't we add doctests that check the error messages being raised?

I am happy to merge the patch "as is", but if someone wanted to submit such a patch I would not be unhappy ;)

Cheers,

Michael

comment:6 Changed 4 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.4.1.alpha0.

Cheers,

Michael

comment:7 Changed 4 years ago by mvngu

Replying to mabshoff:

Well, to be absolutely pedantic: Shouldn't we add doctests that check the error messages being raised?

I am happy to merge the patch "as is", but if someone wanted to submit such a patch I would not be unhappy ;)


Some happiness is available at #5619 :-)

Note: See TracTickets for help on using tickets.