On 11/3/10 6:03 AM, Andrzej Giniewicz wrote:

%pylab (or %sagelab maybe? some functions might work a bit differently
than with pure PyLab)
a=zeros(1000)
a[:100]=1
b=fft(a)
figure()
grid(True)
plot(abs(b))
show()

do exactly the same, without overwriting the names with definitions
from outside of given cell other than what is defined inside it, i.e.
a and b in this example. What do you think? Does it makes some sense
to have %pylab/sagelab cells? I ask because I'd be willing to give it
a try, if I have enough spare time on my hands - I think it's doable
in finite time with only a bit of preparsing - at least it seems so to
me right now.


Sounds good.  The way I'd do it now is:

%python
from pylab import *
a=zeros(1000)
a[:100]=1
b=fft(a)
figure()
grid(True)
plot(abs(b))
savefig('test.png')


However, I notice that this still overwrites things for other cells, as now, even in a normal Sage cell, the plot command refers to the pylab command and not the sage command.

I think all you need to do is add an object to Sage called pylab that does the right thing (see sagenb/sagenb/notebook/worksheet.py, check_for_system_switching() for example). You could even add it to system_names in sagenb/sagenb/notebook/notebook.py (IIRC)

(at least, those are some pointers at where to start looking; sorry I don't have time to be more thorough in my pointers.)

Thanks,

Jason

--
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

Reply via email to