-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble Converting Collections from Python to Julia #231
Comments
You want |
Thank you! |
Could you please give a specific example? @cjdoris function examine(d::AbstractDict{<:AbstractString,<:AbstractVector})
return length(first(d).second)
end Did not figure out how to do it. |
@ShuhuaGao your issue is that the type signature is too specific: >>> from juliacall import Main as jl
>>> d = {"Hello": [1, 2, 3, 4]}
>>> jl.typeof(d)
Julia: PythonCall.PyDict{Any, Any} As you can see, the dict is automatically converted to a You can use >>> from juliacall import convert as jlconvert
>>> jl.typeof(jlconvert(jl.PythonCall.PyDict[jl.String, jl.Vector[jl.Int]], d))
Julia: PythonCall.PyDict{String, Vector{Int64}} (replace |
I'm sure I'm just overlooking something in the docs, so I'm sorry for the redundant question!
I have a dictionary in Python that I'd like to pass into a Julia function. But it is getting converted to type
PyCall.PyDict{Pycall.Py,Pycall.Py}
. I tried to explicitly convert usingPyCall.convert(Dict{String, Any}, my_python_dict)
but it throws:MWE:
Just to double check, I also tried
jl.typeof("a")
and gotString
back.Any thoughts on how to get the dictionary into a Julia Dict?
The text was updated successfully, but these errors were encountered: