Skip to content

How to pass a numpy array into a Julia function? #38

Closed
@ShuhuaGao

Description

@ShuhuaGao

Consider a dummy function inside my custom package EOS:

function dummy(x::AbstractVector)
    @show typeof(x)
end

From Python, I call it as follows

jl.EOS.dummy(np.array([1.1, 2.3]))

and the following error occurs

TypeError: Julia: MethodError: no method matching dummy(::PythonCall.PyIterable{PythonCall.Py})
Closest candidates are:
  dummy(!Matched::AbstractVector{T} where T) at /home/shuhua/Work/opt/EOS/src/EOS.jl:26

According to Conversion to Julia, I expect that a numpy array is converted to a Julia array automatically. Did I miss anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions