[IPython-User] Fortran cell magic

Martín Gaitán gaitan@phasety....
Tue Sep 10 17:54:05 CDT 2013

On Tue, Sep 10, 2013 at 4:19 AM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

> For mosts things that would be a single line to add/ monkey patch:
> https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/config.js#L57
> ,'magic_fortran'      :{'reg':[/^%%fortran/]}
> Unfortunately, it seem code mirror does not support fortran (yet)

I've sent a pull request  with a basic Fortran mode


I hope it will be accepted soon, but then... I should wait for a repack of
ipython's components, right?

Well living in the same repo might not always make sense, but in case like
> %%R/rpy2 %%cython/cython, the magic is just a higher level wrapper to API.
> So it might make sense to have it together.  I don't really use fortran
> (anymore) so I'm not in a good place to judge, this was jus t a
> proposition.
> I might have.
> From a end user point of view, you have either the :
>  - to use fortran with python, the best is IPython with fortran magic.
>  - you have to  install fortran magic.
>  - but fortran magic use f2py
>  - once done if you have the correct f2py version installed it works
> or
>  - to use fortran with python : install f2py
>  - oh, and by the way if you are using ipython you can "Just" do load ext
> numpy.f2py and you have a fortran magic.
> it feels for me exactly the same as %sympyprinting and panda html
> dataframe option.
> they are part of the package, and if you are using IPython you "just" have
> to enable them.
> (I guess a package can even try to detect if it is in IPython at import
> time and register magic automagically
> even if explicit is better than implicit.)

I got the point, but doesn't be a better idea to do this "registration"
automatically in the external package install process? I mean, if I have
ipython installed and I install numpy/f2py, then numpy automatically should
register its "magic for ipython". Once it's already installed, I could
directly use "%%fortran" in a cell without importing anything.

I guess this could be done more or less easily declaring setuptool's "entry
points" in the ipython's setup.py.


For example, this is the architecture used in the nose's plugin machinery:

let me know if it sounds like a good idea

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130910/58ba25eb/attachment.html 

More information about the IPython-User mailing list