[sage-support] some basics of weave
Hi, I was trying to learn a bit of weave, but there seems to be some problem. The code I used is import scipy.weave as weave a, b = 10, 5 code = \ ''' int temp; temp = a; a = b; b = temp; ''' weave.inline(code, ['a', 'b']) print a, b When I ran this code in sage notebook, I got the following error Traceback (most recent call last):print a, b File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/ scipy/weave/inline_tools.py, line 321, in inline results = attempt_function_call(code,local_dict,global_dict) File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/ scipy/weave/inline_tools.py, line 389, in attempt_function_call function_list = function_catalog.get_functions(code,module_dir) File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/ scipy/weave/catalog.py, line 612, in get_functions function_list = self.get_cataloged_functions(code) File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/ scipy/weave/catalog.py, line 526, in get_cataloged_functions if cat is not None and code in cat: File /home/rajeev/bin/sage-4.2/local/lib/python/shelve.py, line 110, in __contains__ return key in self.dict File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/ scipy/io/dumbdbm_patched.py, line 73, in __getitem__ pos, siz = self._index[key] # may raise KeyError KeyError: 0 The same code runs in python, but doesn't do what I want it to do, i.e. interchange the values of a and b. I think this is due to 'call by value' but I am not sure. I hope its OK to ask this question here. Best wishes, Rajeev -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: some basics of weave
On May 12, 8:09 am, Rajeev rajs2...@gmail.com wrote: Hi, I was trying to learn a bit of weave, but there seems to be some problem. In sage notebook, start the cell with %python in the very first line. This tells sage to evaluate the content as pure python. Second, I suggest you to look into cython because that's the weave we use here ;) cell1: %cython cpdef swap(int a, int b): return b, a cell2: print swap(5, 9) gives (9, 5) h -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: some basics of weave
Hi, In sage notebook, start the cell with %python in the very first line. %python doesn't help, getting the same error. suggest you to look into cython because that's the weave we use I am trying to understand the scope of variables while using weave :) Thanks anyway. As I said earlier - The same code runs in python, but doesn't do what I want it to do, i.e. interchange the values of a and b. I think this is due to 'call by value' but I am not sure. I hope its OK to ask this question here. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] strange behavior on assigning string with single quotes
Hi, I am finding a very strange behavior in notebook. Evaluating a = 'hello' gives Traceback (most recent call last): File stdin, line 1, in module File _sage_input_12.py, line 4, in module print _support_.syseval(python, ur\u0027\u0027\u0027a = \u0027hello \u0027\u0027\u0027\u0027, \u0027/home/rajeev/sage_notebook/ sage_notebook.sagenb/home/admin/32/cells/25\u0027) File , line 1 print _support_.syseval(python, ur'''a = 'hello, '/home/rajeev/ sage_notebook/sage_notebook.sagenb/home/admin/32/cells/25') ^ SyntaxError: EOL while scanning string literal There is no problem when I use double quotes. I am using sage 4.2 and I have selected python from the dropdown menu at the top. Rajeev -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: strange behavior on assigning string with single quotes
Let me also add that there is no problem if the dropdown menu at the top is set at sage (the default option). On May 12, 4:31 pm, Rajeev rajs2...@gmail.com wrote: Hi, I am finding a very strange behavior in notebook. Evaluating a = 'hello' gives Traceback (most recent call last): File stdin, line 1, in module File _sage_input_12.py, line 4, in module print _support_.syseval(python, ur\u0027\u0027\u0027a = \u0027hello \u0027\u0027\u0027\u0027, \u0027/home/rajeev/sage_notebook/ sage_notebook.sagenb/home/admin/32/cells/25\u0027) File , line 1 print _support_.syseval(python, ur'''a = 'hello, '/home/rajeev/ sage_notebook/sage_notebook.sagenb/home/admin/32/cells/25') ^ SyntaxError: EOL while scanning string literal There is no problem when I use double quotes. I am using sage 4.2 and I have selected python from the dropdown menu at the top. Rajeev -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-support URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: strange behavior on assigning string with single quotes
Hi Rajeev, This is a bug in older versions of Sage. Please try downloading the latest version over at: http://sagemath.org/download-linux.html. On Wed, May 12, 2010 at 7:43 PM, Rajeev rajs2...@gmail.com wrote: Let me also add that there is no problem if the dropdown menu at the top is set at sage (the default option). On May 12, 4:31 pm, Rajeev rajs2...@gmail.com wrote: Hi, I am finding a very strange behavior in notebook. Evaluating a = 'hello' gives Traceback (most recent call last): File stdin, line 1, in module File _sage_input_12.py, line 4, in module print _support_.syseval(python, ur\u0027\u0027\u0027a = \u0027hello \u0027\u0027\u0027\u0027, \u0027/home/rajeev/sage_notebook/ sage_notebook.sagenb/home/admin/32/cells/25\u0027) File , line 1 print _support_.syseval(python, ur'''a = 'hello, '/home/rajeev/ sage_notebook/sage_notebook.sagenb/home/admin/32/cells/25') ^ SyntaxError: EOL while scanning string literal There is no problem when I use double quotes. I am using sage 4.2 and I have selected python from the dropdown menu at the top. Rajeev -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/sage-support URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- Tim Joseph Dumol tim (at) timdumol (dot) com http://timdumol.com -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Why isn't Sage showing plots from matplotlib/pylab ?
Hello. I'm wondering why these lines doesn't show me any plots: import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.ylabel('some numbers') plt.show() or from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s, linewidth=1.0) xlabel('time (s)') ylabel('voltage (mV)') title('About as simple as it gets, folks') grid(True) show() I'm using Sage from web-browser and those are the only lines that i have wrote to a clear worksheet. 'Sage Version 4.4.1, Release Date: 2010-05-02'. I have Windows XP. I took those examples from the mathplotlib netsite: http://matplotlib.sourceforge.net/users/pyplot_tutorial.html http://matplotlib.sourceforge.net/users/screenshots.html#simple-plot -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Why isn't Sage showing plots from matplotlib/pylab ?
Hi, On Wed, May 12, 2010 at 7:58 PM, zetro jej...@utu.fi wrote: Hello. I'm wondering why these lines doesn't show me any plots: import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.ylabel('some numbers') plt.show() or from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s, linewidth=1.0) xlabel('time (s)') ylabel('voltage (mV)') title('About as simple as it gets, folks') grid(True) show() I'm using Sage from web-browser and those are the only lines that i have wrote to a clear worksheet. 'Sage Version 4.4.1, Release Date: 2010-05-02'. I have Windows XP. I took those examples from the mathplotlib netsite: http://matplotlib.sourceforge.net/users/pyplot_tutorial.html http://matplotlib.sourceforge.net/users/screenshots.html#simple-plot -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org Try using plt.savefig('foo.png') instead of plt.show(). The Sage Notebook automatically displays any files saved in the evaluation directory. This should probably be put in documentation somewhere (if it isn't already). -- Tim Joseph Dumol tim (at) timdumol (dot) com http://timdumol.com -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] linear transformations between vector spaces with named bases?
I have some (hashable) Sage objects, elements of a particular algebra, and I want to view them as the basis of a vector space. Call the objects a, b, c. I think the way to do this in Sage is sage: V = CombinatorialFreeModule(QQ, [a,b,c]) Suppose I have another such vector space: sage: W = CombinatorialFreeModule(QQ, [e,f]) and I define a map between them: sage: B = W.basis() sage: g = V.hom([2*B[e]-B[f], B[e]+B[f], 0], QQ) How do I compute the kernel of this map, or the matrix associated to it (with respect to the chosen bases), or evaluate it on elements of V? For example: sage: BB = V.basis() sage: g(BB[a]) produces an error. So how should I be performing these kinds of calculations? -- John -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] GAP on OSX (sage 4.4.1)
I am unable to run GAP from a network account on my mac. sage: gap('(1,2,3)') raise an exception. sage: gap_console() gives a little more information: Couldn't open saved workspace /Network/Servers/hostname.ca/Users/ tremblayj/.sage//gap/workspace-4762775528093915922 When I use a local account, everything works fine. Can anyone help me? Full session: sage: gap('(1,2,3)') --- TypeError Traceback (most recent call last) /Network/Servers/thales.math.uqam.ca/Users/tremblayj/ipython console in module() /Library/sage/local/lib/python2.6/site-packages/sage/interfaces/ expect.py in __call__(self, x, name) 1030 1031 if isinstance(x, basestring): - 1032 return cls(self, x, name=name) 1033 try: 1034 return self._coerce_from_special_method(x) /Library/sage/local/lib/python2.6/site-packages/sage/interfaces/ expect.py in __init__(self, parent, value, is_name, name) 1449 except (TypeError, KeyboardInterrupt, RuntimeError, ValueError), x: 1450 self._session_number = -1 - 1451 raise TypeError, x 1452 self._session_number = parent._session_number 1453 TypeError: Unable to start gap sage: gap_console() Couldn't open saved workspace /Network/Servers/thales.math.uqam.ca/ Users/tremblayj/.sage//gap/workspace-4762775528093915922 sage: version() 'Sage Version 4.4.1, Release Date: 2010-05-02' sage: -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: GAP on OSX (sage 4.4.1)
On May 12, 3:48 pm, William Stein wst...@gmail.com wrote: 2010/5/12 Jérôme Tremblay jerome.tremb...@gmail.com: I am unable to run GAP from a network account on my mac. When I use a local account, everything works fine. Can anyone help me? What happens if you do export DOT_SAGE=/tmp/your_username before starting Sage. (I'm assuming you're using bash -- if not, set that environ variable appropriately.) This works. But with this, the users will not have their worksheets in their account but on the local computer, right? Thank you, Jerome Tremblay LaCIM (UQAM, Canada) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: GAP on OSX (sage 4.4.1)
2010/5/12 Jérôme Tremblay jerome.tremb...@gmail.com: On May 12, 3:48 pm, William Stein wst...@gmail.com wrote: 2010/5/12 Jérôme Tremblay jerome.tremb...@gmail.com: I am unable to run GAP from a network account on my mac. When I use a local account, everything works fine. Can anyone help me? What happens if you do export DOT_SAGE=/tmp/your_username before starting Sage. (I'm assuming you're using bash -- if not, set that environ variable appropriately.) This works. But with this, the users will not have their worksheets in their account but on the local computer, right? All default user data will be in /tmp instead of $HOME/.sage.The above was mainly meant as a test to see if the problem was really the filesystem... Regarding worksheets, if that's the only really important config info, users could do sage: notebook('/path/to/their/sage/notebook/directory') or sage -notebook /path/to/their/sage/notebook/directory You could make a little bash script that contains the above line, but maybe $HOME/SageNotebook or something... William Thank you, Jerome Tremblay LaCIM (UQAM, Canada) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org