kcrisman, Have you tried putting from sage.matrix.constructor import matrix before M = matrix()?
The problem is that on the Sage command line, a lot of things are imported for you, but "modules" such as DoNothing.py don't import anything. You have to say so explicitly. If you're using a function on the command line, two ??'s will tell you where to import from: sage: matrix?? ... File: /Volumes/HOME/sage/local/lib/python2.5/site-packages/ sage/matrix/constructor.py ... def matrix(arg0=None, arg1=None, arg2=None, arg3=None, sparse=None): """ etc. -- Robert M On Dec 14, 4:50 pm, kcrisman <[EMAIL PROTECTED]> wrote: > Does matrix work in sage -t mode? > > The following works at the command line, of course: > > sage: matrix() > [] > > But if I create a file DoNothing.py which has as its only code > matrix(), and then try to test it, the following happens (ellipses for > readability). If I replace matrix() by range(n) or something else, > there are no problems and the test is successful - after all, there is > no output, and that's what the example demands. I've tried numerous > variations on this, and everything else I've written tests fine - just > things with 'matrix' or its variants don't, and they all give the same > error about matrix being a global variable. > > Thanks for any advice! Apologies if I missed this elsewhere. > - kcrisman > > sage -t Desktop/computer/SAGE/DoNothing.py > ********************************************************************** > File "DoNothing.py", line 10: > ge: donothing(5) > Exception raised: > Traceback (most recent call last): > File "/Applications/.../lib/python/doctest.py", line 1212, in > __run > compileflags, 1) in test.globs > File "<doctest __main__.example_0[1]>", line 1, in <module> > donothing(Integer(5))###line 10: > ge: donothing(5) > File "/Users/.../DoNothing.py", line 13, in donothing > M = matrix() > NameError: global name 'matrix' is not defined > ********************************************************************** > 1 items had failures: > 1 of 2 in __main__.example_0 > ***Test Failed*** 1 failures. > For whitespace errors, see the file .doctest_DoNothing.py > [7.3 s] > exit code: 256 > > ---------------------------------------------------------------------- > The following tests failed: > > sage -t Desktop/computer/SAGE/DoNothing.py > Total time for all tests: 7.4 seconds > > Here is DoNothing.py . > > def donothing(n): > """This function does nothing useful. > > INPUT: > n -- an integer > > EXAMPLES: > Here is my only example. > sage: from DoNothing import * > sage: donothing(5) > > """ > M = matrix() --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com 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://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---