[IPython-User] Fortran cell magic

Martín Gaitán gaitan@phasety....
Mon Sep 9 19:13:52 CDT 2013


Hi Matthias, thanks for you feedback


On Mon, Sep 9, 2013 at 12:16 PM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

>
> My first contribution to IPython is an alpha/hackish cell magic...
>
> Great, thanks, this is a good start. I think there was an embryo of f2py
> magic at some point.
> Maybe you can also scape some code from there ( I don't know maybe there
> was more functionality)
>

Oops, I didn't know that. I've found it here

https://github.com/ipython/ipython/pull/2674

And it's almost the same I did :D (he uses the f2py's api, may be it's a
better idea than to call the command via shell.getoutput()) . I've already
leave a message to the author to merge our work.


Did you know wether or not CodeMirror support Fortran highlighting.
> If so it should be pretty easy to have the notebook switch to fortran mode
> if it sees the %%fortran
> at the start of cell.
>

Cool. How can I do that? Any working example?

You can also add your magic into the ipython cookbook. And don't forget
> that if yo unmake it a python package it can be installed via PIP.
>

sure, it's added to the to-do, but I would like to polish it a bit before:)


> I would also suggest to get closer to f2py and see if they would like to
> integrate this into their own repo, so that importing f2py into ipython
> would almost automagically load fortran magic.
>
See (Break out language magics into their own repos)
> https://github.com/ipython/ipython/issues/3803 for more info.
>

What's the idea behind this? F2py is rarely used programatically (and its
API is a bit rough, btw) and there is no need to import anything related
from the f2py package to use a module compiled through it.

So in the context of an interactive session, do "import numpy.f2py"  would
be the same effort than "%load_ext fortranmagic" and, imho, less explicit
to our purpose.  what do you think about?


PS: Should this kind of message go to ipython-dev list instead of this one?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130909/69120bed/attachment.html 


More information about the IPython-User mailing list