Skip to content

Help with calling a julia function from python when the input is an array of arrays #556

Answered by cjdoris
mestinso asked this question in Q&A
Discussion options

You must be logged in to vote

AFAIR np.array([np.array([1,2,3])]) is actually a matrix, not a vector of vectors. There are no conversions in PythonCall from a matrix to a vector of vectors, so you'll need to make it a vector of vectors yourself.

You could just have a list [np.array([1,2,3])] or do np.array([np.array([1,2,3])], dtype=object). However neither of these will convert to a AbstractVector{<:AbstractVector{<:Real}} because now the type of the elements of the given list or array cannot be inferred (the element type is just object).

I think you'll need to do some manual conversion using juliacall.convert or do the conversion Julia-side.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mestinso
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants