On Wed, Dec 14, 2011 at 4:13 PM, David Roe <r...@math.harvard.edu> wrote: > I helping a colleague try to wrap some magma code that uses verbose > print statements. Apparently, just setting the verbose flag is not > enough: > > sage: magma.SetVerbose("Factorization",1) > sage: magma.Factorization(56654654654464) > [ <2, 11>, <1289, 1>, <21461137, 1> ] > > Instead, you have to use StdOutContext, which prints a whole bunch of > extra stuff:
What is "StdOutContext"? wstein@ubuntu:chow_heeegner$ sage ---------------------------------------------------------------------- | Sage Version 4.8.alpha5, Release Date: 2011-12-13 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- ********************************************************************** * * * Warning: this is a prerelease version, and it may be unstable. * * * ********************************************************************** Loading Sage library. Current Mercurial branch is: pre4260 sage: StdOutContext NameError: name 'StdOutContext' is not defined -- sage: from sage.interfaces.expect import StdOutContext sage: StdOutContext? ... Construct a new context in which all communation between Sage and a subprocess interfaced via pexpect is printed to stdout. ----------- Wow, that's pretty cool. I didn't know about this feature. Anyway, here is how to get what you want to work: sage: magma.SetVerbose("Factorization",1) sage: print magma.eval('Factorization(56654654654464)') Integer main factorization (primality of factors will be proved) Effort: 3 Seed: 2503141013 0 Number: 56654654654464 Entering SQUFOF 27663405593 [ <2, 11>, <1289, 1>, <21461137, 1> ] -- Using this doesn't work sage: magma.Factorization(56654654654464) [ <2, 11>, <1289, 1>, <21461137, 1> ] ... since it really (1) makes the variable _sage_[3] in the Magma session, ignoring all printed output: sage: s = magma.Factorization(56654654654464) sage: s.name() '_sage_[3]' ... *then*, prints out the string repr of _sage_[3] sage: s [ <2, 11>, <1289, 1>, <21461137, 1> ] It would be interesting and desirable to make SetVerbose somehow do something differently, but I have no idea how this could be made to fit into the current expect framework. Nobody has ever requested this before, as far as I know, so it's probably not a huge issue. -- William > > sage: with StdOutContext(magma): > ....: magma.Factorization( 56654654654464) > ....: > Append(~_sage_, 0); > Append(~_sage_, 0); >>>>_sage_[5]:=56654654654464; > _sage_[5]:=56654654654464; >>>>Append(~_sage_, 0); > Append(~_sage_, 0); >>>>_sage_[9]:=Factorization(_sage_[5]); > _sage_[9]:=Factorization(_sage_[5]); > Integer main factorization (primality of factors will be proved) > Effort: 3 > Seed: 1 168527 > Number: 56654654654464 > Entering SQUFOF 27663405593 >>>>_sage_[5]:=0; > _sage_[5]:=0; >>>>_sage_[9]; > _sage_[9]; > [ <2, 11>, <1289, 1>, <21461137, 1> ] >>>>[ <2, 11>, <1289, 1>, <21461137, 1> ] > > It seems like SetVerbose for magma is broken; is there something I'm missing? > David > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org