Skip to content

Commit

Permalink
Bundle DiffEqPy.jl into diffeqpy
Browse files Browse the repository at this point in the history
closes #22
  • Loading branch information
tkf committed Apr 27, 2018
1 parent 0a8a129 commit e92b71f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include README.md
include LICENSE.md
include docs/*.txt
include diffeqpy/*.jl
19 changes: 18 additions & 1 deletion diffeqpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import os

from julia import Julia

script_dir = os.path.dirname(os.path.realpath(__file__))


def setup():
jul = Julia()
jul.using("DiffEqPy")

# Load ./setup.jl
include = jul.eval('include') # jul.include does not work sometimes
include(os.path.join(script_dir, 'setup.jl'))

# Make Julia functions and types exported from
# DifferentialEquations accessible:
jul.add_module_functions('DifferentialEquations')

# pysolve has to be treated manually:
# See: https://github.com/JuliaPy/pyjulia/issues/117#issuecomment-323498621
jul.pysolve = jul.eval('pysolve')

return jul
14 changes: 14 additions & 0 deletions diffeqpy/setup.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using DifferentialEquations
using PyCall

pysolve = PyCall.pyfunctionret(solve,Any,Vararg{PyCall.PyAny})
inspect = pyimport("inspect")

function DiffEqBase.numargs(f::PyCall.PyObject)
haskey(f,:py_func) ? _f = f[:py_func] : _f = f
if PyCall.pyversion < v"3.0.0"
return length(first(inspect[:getargspec](_f)))
else
return length(first(inspect[:getfullargspec](_f)))
end
end

0 comments on commit e92b71f

Please sign in to comment.