#7939: shorten doctests in sage/rings/multi_polynomial_ideal.py
-------------------------------+--------------------------------------------
   Reporter:  rlm              |       Owner:  tbd       
       Type:  defect           |      Status:  needs_info
   Priority:  major            |   Milestone:  sage-4.3.2
  Component:  interfaces       |    Keywords:            
     Author:  Martin Albrecht  |    Upstream:  N/A       
   Reviewer:                   |      Merged:            
Work_issues:                   |  
-------------------------------+--------------------------------------------

Comment(by AlexGhitza):

 Replying to [comment:12 malb]:
 > Do you like the name "ff" by the way (function factory)? It should be
 short but precise. "factory" is out, because there is a module in Singular
 called factory (for factorisation).

 Well, the other possibility that springs to mind is "funfact" :)
 Seriously, I think "ff" is fine.

 >
 > Works for me, I just tried it.

 And now it also works for me.  I restarted sage and tried it again and it
 seems fine.  I'm not sure what triggered it before.  I'll let you know if
 I happen to run into it again.

 >
 > > I tried groebner? and groebner?? (which give very different results)
 but I couldn't get an
 > answer quickly.
 >
 > {{{groebner?}}} will show you the Singular help while {{{groebner??}}}
 will show you the generic Singular function interface docstring. Maybe we
 should merge them in {{{groebner?}}}? Let me know in what order, and I can
 implement it.

 Here is what I get when I do these two:

 With {{{groebner?}}} I get the Singular help followed by

 {{{
 Call def:       groebner(self, *args, ring=None, interruptible=True,
 attributes=None)

 Call docstring:

             Call this function with the provided arguments ``args`` in the
             ring ``R``.

             INPUT:

             - ``args`` - a list of arguments

             - ``ring`` - a multivariate polynomial ring

             - ``interruptible`` - if ``True`` pressing Ctrl-C during the
                                   execution of this function will
                                   interrupt the computation (default:
 ``True``)

             - ``attributes`` - a dictionary of optional Singular
                                attributes assigned to Singular objects
 (default: ``None``)

             EXAMPLE::

                 sage: from sage.libs.singular.function import
 singular_function
                 sage: size = singular_function('size')
                 sage: P.<a,b,c> = PolynomialRing(QQ)
                 sage: size(a, ring=P)
                 1
                 sage: size(2r,ring=P)
                 1
                 sage: size(2, ring=P)
                 1
                 sage: size(2)
                 Traceback (most recent call last):
                 ...
                 ValueError: Could not detect ring.
                 sage: size(Ideal([a*b + c, a + 1]), ring=P)
                 2
                 sage: size(Ideal([a*b + c, a + 1]))
                 2
                 sage: size(1,2, ring=P)
                 Traceback (most recent call last):
                 ...
                 RuntimeError

                 sage: size('foobar', ring=P)
                 6

             Show the usage of the optional ``attributes`` parameter::

                 sage: P.<x,y,z> = PolynomialRing(QQ)
                 sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
                 sage: I = Ideal(I.groebner_basis())
                 sage: hilb = sage.libs.singular.ff.hilb
                 sage: hilb(I) # Singular will print // ** _ is no standard
 basis

             So we tell Singular that ``I`` is indeed a Groebner basis::

                 sage: hilb(I,attributes={I:('isSB',)}) # no complaint from
 Singular
 }}}

 If I do {{{groebner??}}} I get

 {{{
 Type:           SingularLibraryFunction
 Base Class:     <type
 'sage.libs.singular.function.SingularLibraryFunction'>
 String Form:    groebner (singular function)
 Namespace:      Interactive
 File:           /home/ghitza/sage-devel/local/lib/python2.6/site-
 packages/sage/libs/singular/function.so
 Definition:     groebner(self, *args, ring=None, interruptible=True,
 attributes=None)
 Source:
 cdef class SingularLibraryFunction(SingularFunction):
     """
     EXAMPLES::

         sage: from sage.libs.singular.function import
 SingularLibraryFunction
         sage: R.<x,y> = PolynomialRing(QQ, order='lex')
         sage: I = R.ideal(x, x+1)
         sage: f = SingularLibraryFunction("groebner")
         sage: f(I)
         [1]
     """
     def __init__(self, name):
         """
         Construct a new Singular kernel function.

         EXAMPLES::

             sage: from sage.libs.singular.function import
 SingularLibraryFunction
             sage: R.<x,y> = PolynomialRing(QQ, order='lex')
             sage: I = R.ideal(x + 1, x*y + 1)
             sage: f = SingularLibraryFunction("groebner")
             sage: f(I)
             [y - 1, x + 1]
         """
         super(SingularLibraryFunction,self).__init__(name)
         self.call_handler = self.get_call_handler()

     cdef BaseCallHandler get_call_handler(self):
         cdef idhdl* singular_idhdl = ggetid(self._name, 0)
         if singular_idhdl==NULL:
             raise NameError("Function '%s' is not defined."%self._name)
         if singular_idhdl.typ!=PROC_CMD:
             raise ValueError("Not a procedure")

         cdef LibraryCallHandler res = LibraryCallHandler()
         res.proc_idhdl = singular_idhdl
         return res

     cdef bint function_exists(self):
         cdef idhdl* singular_idhdl = ggetid(self._name, 0)
         return singular_idhdl!=NULLCall def:    groebner(self, *args,
 ring=None, interruptible=True, attributes=None)

 Call docstring:

             Call this function with the provided arguments ``args`` in the
             ring ``R``.

             INPUT:

             - ``args`` - a list of arguments

             - ``ring`` - a multivariate polynomial ring

             - ``interruptible`` - if ``True`` pressing Ctrl-C during the
                                   execution of this function will
                                   interrupt the computation (default:
 ``True``)

             - ``attributes`` - a dictionary of optional Singular
                                attributes assigned to Singular objects
 (default: ``None``)

             EXAMPLE::

                 sage: from sage.libs.singular.function import
 singular_function
                 sage: size = singular_function('size')
                 sage: P.<a,b,c> = PolynomialRing(QQ)
                 sage: size(a, ring=P)
                 1
                 sage: size(2r,ring=P)
                 1
                 sage: size(2, ring=P)
                 1
                 sage: size(2)
                 Traceback (most recent call last):
                 ...
                 ValueError: Could not detect ring.
                 sage: size(Ideal([a*b + c, a + 1]), ring=P)
                 2
                 sage: size(Ideal([a*b + c, a + 1]))
                 2
                 sage: size(1,2, ring=P)
                 Traceback (most recent call last):
                 ...
                 RuntimeError

                 sage: size('foobar', ring=P)
                 6

             Show the usage of the optional ``attributes`` parameter::

                 sage: P.<x,y,z> = PolynomialRing(QQ)
                 sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
                 sage: I = Ideal(I.groebner_basis())
                 sage: hilb = sage.libs.singular.ff.hilb
                 sage: hilb(I) # Singular will print // ** _ is no standard
 basis

             So we tell Singular that ``I`` is indeed a Groebner basis::

                 sage: hilb(I,attributes={I:('isSB',)}) # no complaint from
 Singular
 }}}

 (Sorry these are a bit long.)  But it looks like the first includes part,
 but not all, of the second.

 What would I like to see?  (I'm not sure if this is feasible without a lot
 of work, but here goes.)  If I type {{{groebner?}}} I want to know how to
 use {{{groebner}}} from Sage.  For instance, seeing the example

 {{{
 sage: groebner = sage.libs.singular.ff.groebner
 sage: P.<x, y> = PolynomialRing(QQ)
 sage: I = P.ideal(x^2-y, y+x)
 sage: groebner(I)
 [x + y, y^2 - y]
 }}}

 and maybe a couple more showing other arguments/options would get me
 started with using the function.  So I would think that it's more useful
 and natural to have something like the above, followed by the Singular
 help that shows all the options, bells, and whistles.  Again, I don't know
 if this is feasible, but it would be nice.

 If that's not possible, maybe have a docstring that shows how to use some
 of the more popular Singular functions from Sage.  If that's followed by
 the Singular help for the particular function I'm looking at at the
 moment, I should be able to put the two together and understand how to do
 things.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7939#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB
-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.


Reply via email to