[SciPy-User] calling Julia module from Python?
asreeve
asreeve at maine.edu
Fri May 15 12:47:06 EDT 2015
I would like some guidance in using the Julia Language (v:0.3.8) from
Python(v:3.4.3), to see if it can be used for creating fast modules
for Python scripts.
I've written a short function in Julia and would like to call it from
a python script. To get started, I'm trying to load the Julia script
into an ipython shell. I can call the module from Julia, and can
execute short bits of Julia in the ipython shell.
Here's where I'm at now (the Julia module I'm calling is at the end of
this message):
Using Julia
===========
julia> using snow_frac2
julia> snow_frac2.snow_fraction2(1.)
0.5
===========
Using Python
============
In [1]: import julia
In [2]: jl=julia.Julia()
In [3]: jl.eval('sin(3.14)')
Out[3]: 0.0015926529164868282
===========
I'd like to call the "snow_frac2.jl" module below from the ipython
interpreter, just like I did in in Julia, and use the snow_fraction2
function. I've attempted a variety of commands
(eg. foo=jl.call('snow_frac2.jl')) but just get "JuliaError"s. Can
anyone show the proper incantation to call a Julia module from Python?
I've tried updating to a more recent verion of Julia, but that did not
seem to help (although I gave up on this pretty quickly).
Thanks for any help you can provide,
Andy
==snow_frac2.jl==
module snow_frac2
function snow_fraction2(temptr::Float64)
if temptr<-1.
fraction=1.0
elseif temptr>3.0
fraction=0.0
else
fraction=(temptr+1.0)/(4.0)
end
return fraction
end
end
....................................
Andrew Reeve
School of Earth and Climate Sciences
University of Maine
Orono, ME 04469
More information about the SciPy-User
mailing list