On Dec 17, 2007 5:28 PM, kcrisman <[EMAIL PROTECTED]> wrote: > > Robert M said: Have you tried putting from sage.matrix.constructor > import matrix before M = matrix()? > > That was a good idea! Unfortunately, it didn't work, even when trying > the file in several different directories (is that possibly what's > wrong?). I used this, and the same "matrix as global variable" > problem arose. > > EXAMPLES: > Here is my only example. > sage: from DoNothing import * > sage: from sage.matrix.constructor import matrix > sage: donothing(5) > > """ > M = matrix() > > Interestingly, if I changed the example to try to import something > nonsensical, like > > sage: from sage.matrix.constructor import jabba > > then sage -t correctly tells me that I am trying to import something > nonexistent as an error, so I presume (perhaps wrongly) that matrix is > getting imported when I use the correct syntax. Nonetheless I get > this same global variable problem once I switch back to importing > 'matrix' (or not importing at all). > > Point of information is that I am still at 2.8.12 as I am a little > afraid of losing my notebook files with -upgrade, but I don't think > that would affect things either.
Upgrading will not make you lose any notebook files or otherwise corrupt them. The one difference is that in sage-2.8.>=15 when you do sage -notebook it creates the notebook state files in $HOME/.sage/sage_notebook instead of the current directory. You can still use the sage notebook files in the current directory by doing sage -notebook sage_notebook Regarding your questions above, here are three examples that each involve doctesting: Doctesting a .sage file: rank4:tmp was$ more nothing.sage def foo(): """ sage: foo() [] """ return matrix() rank4:tmp was$ sage -t nothing.sage sage -t nothing.sage Example 0 (line 2) [2.3 s] ---------------------------------------------------------------------- All tests passed! Total time for all tests: 2.3 seconds Doctesting a .py file that uses sage: rank4:tmp was$ more a.py from sage.all import matrix def foo(): """ sage: from a import * sage: foo() [] """ return matrix() rank4:tmp was$ sage -t a.py sage -t a.py [1.6 s] ---------------------------------------------------------------------- All tests passed! Total time for all tests: 1.6 seconds Doctesting a py file that happens to use Sage, but using the standard Python doctest framework. rank4:tmp was$ more b.py from sage.all import matrix def foo(): """ >>> foo() [] """ return matrix() if __name__ == '__main__': import doctest, sys s = doctest.testmod(sys.modules[__name__], verbose=True) rank4:tmp was$ sage -python b.py Trying: foo() Expecting: [] ok 1 items had no tests: __main__ 1 items passed all tests: 1 tests in __main__.foo 1 tests in 2 items. 1 passed and 0 failed. Test passed. -- William --~--~---------~--~----~------------~-------~--~----~ 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/ -~----------~----~----~----~------~----~------~--~---