I am currently writing an interface between a Python program and a Julia Package; I would like to call the functions in the Julia package from Python. The functions in the Julia package all have type declarations, and for better or for worse, I am not able to change this . I could do is write function wrappers for all functions in the package, but I would like to avoid that if possible.
When the Julia functions have basic type declarations, like Int64, Float, or Bool, the conversion seems to happen, but not for numpy arrays.
Is there a way to have PythonCall/JuliaCall automatically convert numpy arrays into Julia arrays when passing them as arguments to a function? For example, I would like to define the Julia function:
function matrix_func(x::Array{Float64, 2})
Do some stuff
end
And then, on the Python side:
import numpy as np
from juliacall import Main as jl
my_array = np.array([[1,2,3], [4,5,6]])
jl.include("File containing matrix_func definition")
jl.matrix_func(my_array)
For my use case, I am completely fine with performing copying operations. I am aware that copying operations will allocate memory unnecessarily, but in my case I’m only calling a few functions from Julia to set up a Julia object which contains all the data needed for our task, after which everything will be done in Julia.
According to the documentation here: Python to Julia · PythonCall & JuliaCall, the user can set custom conversion rules, but I do not understand whether I can make use of this to perform automatic type conversion when calling Julia functions from Python, or if this is only for implementing/overriding the behavior for when the user calls pyconvert directly.