You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I've got a quistion as for the PyJulia functionality. How do I dispatch a Julia method for different objects defined in Python?
I assume the existence of an underlying mapping between native Python and Julia types: int -> Integer, float -> Float64, but at the same time np.array -> Array, which makes me think that I can customize this sort of mapping and connect MyClassPy -> MyClassJulia. Is that so?
Thank you in advance!
example.py
classMyClassA:
passclassMyClassB:
passfromjuliaimportJuliajulia=Julia()
julia.eval("@eval Main import Base.MainInclude: include")
fromjuliaimportMainMain.include("example.jl")
foo(MyClassA()) # "Dispatched to MyClassA version"foo(MyClassB()) # "Dispatched to MyClassB version"
example.jl
# How can I access MyClassA and MyClassB types in Julia?some_magic_way_to_include_structures_defined_in_python()
functionfoo( custom_pyobject ::MyClassA )
println("Dispatched to MyClassA version")
endfunctionfoo( custom_pyobject ::MyClassB )
println("Dispatched to MyClassB version")
end
The text was updated successfully, but these errors were encountered:
Hello, I've got a quistion as for the PyJulia functionality. How do I dispatch a Julia method for different objects defined in Python?
I assume the existence of an underlying mapping between native Python and Julia types:
int
->Integer
,float
->Float64
, but at the same timenp.array
->Array
, which makes me think that I can customize this sort of mapping and connectMyClassPy
->MyClassJulia
. Is that so?Thank you in advance!
example.py
example.jl
The text was updated successfully, but these errors were encountered: