On Sun, Feb 15, 2009 at 3:33 PM, Ondrej Certik <ond...@certik.cz> wrote:
>
> On Wed, Feb 11, 2009 at 7:13 PM, Nick Alexander <ncalexan...@gmail.com> wrote:
>>
>>> Indeed, it was a oneliner:
>>>
>>> diff -r b0aa7ef45b3c sage/server/notebook/user_conf.py
>>> --- a/sage/server/notebook/user_conf.py       Mon Jan 05 23:03:45 2009 -0800
>>> +++ b/sage/server/notebook/user_conf.py       Wed Feb 11 08:58:59 2009 -0800
>>> @@ -4,7 +4,7 @@
>>> import conf
>>>
>>> defaults = {'max_history_length':500,
>>> -            'default_system':'sage',
>>> +            'default_system':'python',
>>>             'autosave_interval':3*60,   # (in seconds)
>>>             'default_pretty_print': False
>>>             }
>>>
>>>
>>> Is there some better way, so that I don't have to modify Sage sources?
>>
>> You could monkey patch it from init.sage (you don't want to see my
>> init.sage):
>>
>> import sage.server.notebook.user_conf
>> sage.server.notebook.user_conf.defaults['default_system'] = 'python'
>
> Thanks for the tip, I'll try it.

Doing that isn't evil either.  Well, at least I can tell you that it matches
with the author's (me) original intentions for how

     sage.server.notebook.user_conf.defaults

might be used.

>
> So I got our software running in Sage over the web! Here is a very
> simple example:
>
> http://nb.hpfem.org:8000/home/pub/5/
>
> It uses a mesh, that I uploaded to the worksheet, and then it loads it
> into our C++ code. That's it. I had to disable more interesting stuff,
> because it was depending on umfpack, but I had some problems
> installing it in Sage, and it is not needed anyway, as I want to use
> scipy.sparse for solving stuff, or pysparse, or pets4py or slepc4py,
> but I want to call it from Python, not from C++.
> So I need to work on this more to get everything polished, but now I
> can see that it will work.
>
> Great job with the notebook, it's exactly what I need!

Cool.  By the way, I made an account on your server above and tried
the above example, and all went well.

>
> I have couple questions:
>
> 1) how can I change what gets imported by default in an empty
> worksheet? I use Python mode, but sage still gets imported and it
> polutes the namespace. :)

Hmmm... First, this can definitely be fixed.
[takes 10 minutes]
OK, I wrote a small patch that modifies the sage notebook so that it
starts up all worksheet processes in Pure Python mode without
importing the sage library.  It's a 2-line modification to
notebook/worksheet.py.  See attached.  After applying this the
individual worksheets will actually startup a lot faster and be more
lightweight, but of course no specific sage functionality is available
unless one does  "import sage.all".  Tab completion and introspection
still works fine though without importing sage.all.
gh
> 2) How can I get better tracebacks when something goes wrong? Example:
>
> import hermes2d
> m = hermes2d.Mesh()
> m.load()
>
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/home/ondrej/nbfiles/worksheets/ondrej/0/code/7.py", line 6, in 
> <module>
>    print _support_.syseval(python, ur'''m.load()''',
> '/home/ondrej/nbfiles/worksheets/ondrej/0/cells/12')
>  File 
> "/home/ondrej/ext/sage-3.2.3-Debian4.0-32bit-Intel-i686-Linux/local/lib/python2.5/site-packages/sage/server/support.py",
> line 323, in syseval
>    return system.eval(cmd)
> TypeError: eval() takes at least 3 arguments (2 given)
>
>
> The m.load() expects one parameter, I didn't give it any, but it is
> not apparent from the tracebakc what went wrong.

That's a bug in the sage notebook when using another mode (e.g.,
Python) and TypeError is raised running some code. It's interesting
that nobody seems to have reported this before.  I've reported this as
trac #5282:

http://trac.sagemath.org/sage_trac/ticket/5282

I have posted a patch there that fixes this bug.  You should review it
so that it gets into sage asap.

> 3) I want to use matplotlib for plotting, or maybe some other library,
> in any case the result will be a png image. Here are couple examples
> how it can be used in the notebook:
>
> http://nb.hpfem.org:8000/home/pub/2/
> http://nb.hpfem.org:8000/home/pub/3/
> http://nb.hpfem.org:8000/home/pub/4/
>
> Slide to the bottom of the page to see the image. However, I noticed
> with this approach, that if I update the plotting commands and
> regenerate the .png image, the result gets messed up sometimes and I
> had to stop the worksheet, restart it and reevaluate all cells again,
> then it works. Is this a known problem? What is the workaround?

In sage mode, I've never seen problems like this.  Weird.   It should
just work.   Maybe this is a problem with using python mode, and the
directory
not being properly changed or something.  What happens if you make
sure all the images have *different* filenames (say something random)?

> I am impressed how usable the notebook is.

Thanks.

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Attachment: no_sage_library.patch
Description: Binary data

Reply via email to