On Fri, Jul 24, 2009 at 11:22 AM, Simon King<[email protected]> wrote: > > Hi All! > > On 24 Jul., 16:55, Ethan Van Andel <[email protected]> wrote: > ... >> If I set it up like this, it seems like it won't test the "long time" >> one and then will fail the others because it doesn't know what "m" is. >> Is there proper way to handle this? > > I understand this question as follows: > If one places the comment "# long time" after one line of the doc > tests, this line is not executed, unless the flag "-long" is given. > But this means that usually all subsequent lines of the doc tests > might fail, since the result of the "long" computation is not > available. So, is it really needed to put another "#long time" comment > for *each* line that depends on the one line that is really long? Or > is there a more elegant way?
No, this is the only way. > A similar question may be raised concerning optional tests. If I > remember correctly, if the doc string contains the three words > "optional", "package" and "installed" then the *whole*(!) doc test is > skipped, unless the "-optional" flag is used. I think that was removed long ago. Now one does sage: code # optional - component This allows for doctesting individual optional components only. > So, the general problem is this: > - Suppose you have a long doc string with many examples; say, a doc > string that exposes the functionality of a big package, and where the > doc tests provide a step-by-step introduction. > - Suppose further that *some* (but not all) examples require an > optional package being installed, and that there is one line with a > long computation time on which depend, say, the following 10 lines, > but afterwards it is just "testing as usual". > Is there a fine grained way to tell which examples should be executed > if one specific flag (not restricted to -long or -optional) is passed > to "sage -t" ? > > I think it would be nice to have the possibility to do the following > in doc tests: > > """ > EXAMPLES:: > > sage: R.<x,y,z> = QQ[] > #<if testflag contains "long"> > sage: I = ... # some nasty ideal > sage: G = I.groebner_basis() > #<if (testflag contains "magma") or (testflag contains "optional") >> > sage: GM = I.groebner_basis(algorithm="magma") > sage: G == GM > True > #<end if> > #<else> > sage: I = ... # some less nasty ideal > sage: G = I.groebner_basis() > #<end if> > sage: p = ... # some ideal that both belongs to the nasty and the > less nasty ideal > sage: p.reduce(G) > 0 > > """ > > So, in the above example, using the flag "-long", some lengthy Gröbner > basis is computed. If, in addition, "-optional" or "-magma" is given, > the Gröbner basis is compared with the output of Magma. If "-long" is > not used then an easier example is done. In all cases, it is tested > whether a polynomial in the ideal reduces to zero. > > I don't know the sage test script, but shouldn't it be possible to > modify it such that above is possible, even allowing "custom" flags > ( #<if testflag contains "your_favourite_flag">)? That sounds complicated and potentially very confusing to users who cut and paste random snippets of code in hoping they will work. william --~--~---------~--~----~------------~-------~--~----~ 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-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
