[IPython-dev] notebook questions

Jason Grout jason-sage@creativetrax....
Fri Sep 16 22:20:39 CDT 2011


On 9/16/11 6:35 PM, MinRK wrote:
>
>
> On Fri, Sep 16, 2011 at 15:50, Jason Grout <jason-sage@creativetrax.com
> <mailto:jason-sage@creativetrax.com>> wrote:
>
>     On 9/16/11 3:37 PM, Chris Kees wrote:
>      > Hi,
>      >
>      > I updated my source on the notebook after I read Fernando's post.
>     Nice
>      > work! Couple of questions:
>      >
>      > Is there a way to use reST in the text boxes? It seems like it
>     sort of
>      > works but doesn't get the ::
>      >
>      > If I put the notebook safely inside our firewall, would it be
>      > reasonable to just let 5-10 people use the same server or do you
>      > foresee problems down the road? I've set up a sage server partly for
>      > that purpose, but having the ipython notebook available could have
>      > some advantages. For example, we're running a computational mechanics
>      > seminar where it would be nice to share some simple mpi programs, say
>      > in the 8-16 processor range. I don't think we can do that in sage
>     yet,
>      > right?
>
>     (answering the Sage question here...) What do you mean when you say
>     "share some simple mpi programs"?  Do you mean running the mpi programs
>     from the command line, or sharing the C code files, or using mpi4py to
>     run the programs?  If you can do it in python or on the command line,
>     you can likely do it in Sage.  Feel free to email the sage-support list;
>     I'm sure we can help you there.
>
>
>
>      >
>      > In the docs, it talks about the python roundtrip not being
>     guaranteed.
>      > What about a sage round trip capability for the notebooks?
>
>     I think that might be possible, though it would require ipython being
>     able to have "text cells" with arbitrary html, rather than just
>     markdown.  The Sage notebook format looks something like:
>
>
> since (almost) arbitrary html is valid markdown, I don't expect a
> problem there.  The first notebook draft had html text cells, but we
> never found any HTML we wanted to use that didn't work as-is in
> markdown, so we disabled it to prevent unnecessary clutter.  If there
> are real HTML use cases for which the markdown transforms html
> inappropriately, we can easily turn it back on.

Good point about streamlining things.  We've found it useful to be able 
to put arbitrary html in (think of a worksheet as an html page with 
cells on it---it's a more fluid document than just text, worksheet, 
text, worksheet, etc.).  For example, one person asked about putting two 
cells side-by-side, and that was pretty easy to do by writing the 
necessary table commands before and after the cells.  I'm curious: can 
you do something like that (embed a <td> before a compute cell and a 
</td> after a compute cell to put the compute cell in a table)?  Or are 
your text cells self-contained snippets in the document?

I like the idea of a worksheet simply being a webpage (with all the 
possible html capabilities), with special cells that evaluate code 
somewhere in the page, or insert WYSIWYG editors, or do interactive 
graphics, etc.



>
>
>     arbitrary html
>
>     {{{
>     input
>     ///
>     output
>     }}}
>
>     arbitrary html
>
>     {{{
>     input
>     ///
>     output
>     }}}
>
>     arbitrary html
>
>     etc.
>
>
> That seems simple enough, though after playing with a few sage
> worksheets, it looks like if you make an HTML cell, it is
> indistinguishable from a code cell in the exported file.  Presumably,
> IPython would only want the Python/Sage cells as code cells, whereas all
> the latex, text, and html cells should come out as text.  If Sage
> doesn't distinguish between these in the file-format, then I'm not sure
> what we should do.  Detecting the language based purely on content will
> certainly not be acceptable.
>

I think you may be confusing %html cells (which are just code cells 
whose output is spliced into the html document, exactly as if we had 
called the html() command, and similar to what would happen if your 
output was a text/html mimetype and spliced into the document) and what 
I'm calling arbitrary html above.  Anything that is typed into the code 
cell is considered a code cell, including %html cells, etc.  To edit the 
arbitrary html that I'm talking about above, shift-click on the blue 
insert-cell bar to open up what we call a "text cell" (as compared to a 
code cell).  A TinyMCE WYSIWYG html editor will pop up.





> But the fact that Sage can have HTML that is part of a cell, as well as
> HTML that is *not* part of a cell makes it clear that a roundtrip will
> not result in an identical notebook.  It may have the same content, but
> it will have changed structure at least partly.  This is what we mean
> when we talk about lacking roundtrip support - not that you can't import
> to/export from a format, but that doing so is not guaranteed to preserve
> the entire document structure.

Yes, of course.  For example, interacts wouldn't work very well.  But I 
think a more modest goal of having the inputs round-trip and the html 
between code cells round-trip might be achievable.  What about files 
attached to the notebooks?  In Sage, we can attach lots of files to a 
worksheet in a DATA directory.  Also, the graphics are not inlined png 
(as I notice the ipython notebook has), but are stored in cell-specific 
output directories.


Jason



More information about the IPython-dev mailing list