[IPython-dev] generating input cells dynamically
Zoltán Vörös
zvoros at gmail.com
Fri Mar 21 15:21:38 EDT 2014
Hi Thomas,
On 21/03/14 18:56, Thomas Kluyver wrote:
> Hi Zoltán,
>
> On 21 March 2014 10:00, Zoltán Vörös <zvoros at gmail.com
> <mailto:zvoros at gmail.com>> wrote:
>
> I have a project, where I would have to plot hundreds of data
> sets, and for various reasons, I would like to place each plot in
> separate cell in the notebook. Is there a way to do this
> automatically? I know what the input cells should contain, it is
> only that I don't want to execute each cell by hand, for each plot
> takes 1-2 minutes to calculate. The only thing I could come up
> with for now is that I generate a notebook with the required cells
> on the command line, load the notebook in the browser, and then
> hit "Run All", but it would be great, if it was possible in a
> somewhat more elegant way.
>
>
> Once you've generated the notebook, you could use runipy to run it
> without having to go through the noteboko UI:
> https://github.com/paulgb/runipy/
>
Thanks a lot! This is a very interesting project, and very new, too.
Indeed, had I asked the question yesterday, you wouldn't have been able
to point to this repository:) But I definitely foresee myself using this
a lot.
In the meantime, I have been trying to generate the code in the notebook
itself. I believe, this (or something very similar) should work:
%%javascript
for(var i=0; i < 3; i++) {
IPython.notebook.insert_cell_below('code')
var cell = IPython.notebook.get_selected_cell()
cell.set_text('plot(' + i + '*sin(x))')
cell.select()
}
Now, the four cells are created (it should be 3, but what the heck!),
and inserted in the notebook, yet, only 'plot(2*sin(x))' is displayed,
and only in the first cell. Is this the intended behaviour?
Cheers,
Zoltán
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140321/cfd8ffd3/attachment.html>
More information about the IPython-dev
mailing list