[SciPy-user] From Python to Fortran, Mathematica and back

Fernando Perez Fernando.Perez at colorado.edu
Wed Oct 5 01:46:28 EDT 2005


Hi all,

Here are a few things which I realized might be of interest to others:

http://amath.colorado.edu/faculty/fperez/python/code

Some in our group still write a fair amount of Fortran source code, yet often
they need constants or arrays in their source, which can be quickly computed
using python/scipy's convenient resources.  The py2fortran module will 
generate syntactically valid Fortran source (either to a string or on disk) 
for python variables.

We also use mathematica heavily, so I've also included a pair of files to do
the same job (exporting variables from one language to another), but for
mathematica <-> Python.  Note that the mathematica stuff is older and less
tested, but it works reasonably well.

All of this is fairly brittle code, since it relies on delicate formatting of
the output (in particular, the mathematica-related routines use
Numeric.array_repr, which may have changed in the new core).  Still, it may
prove to be a big time-saver for some (it is for us here).

Perhaps with a bit of review/cleanup from others, this kind of functionality
(if it's of interest) can be folded in the new scipy, in the i/o facilities
module.  I post it here mainly to gauge community interest, and to give back a
bit after Travis' huge contribution with the new core.

Regards,

f




More information about the SciPy-User mailing list