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
If you're in PyJulia and grabbed some Julia object which has custom +/-/*/etc.. defined, it'd be nice if you can do that directly in Python. E.g.
In [1]: %load_ext julia.magic
Initializing Julia interpreter. This may take some time...
In [2]: %julia using LinearAlgebra
In [3]: x = %julia I
In [4]: 2*x
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-cac53a56d728> in <module>
----> 1 2*x
TypeError: unsupported operand type(s) for *: 'int' and 'PyCall.jlwrap'
where that error is the current behavior but it would be nice if it instead returned:
<PyCall.jlwrap UniformScaling{Int64}
2*I>
I think I can probably implement this if you think you'd accept this functionality.
I think the direction of PyBase.jl is the way to go. That is to say, implement it as a Julia package; or rather, the current plan is to put it in PyCall (yay!): #617. It's in the PyCall 2.0 roadmap #629 so I think we will eventually have this out-of-the-box. If you want to make it happen sooner, see my comment here: #617 (comment)
Let me close this and let's continue the discussion in #617
If you're in PyJulia and grabbed some Julia object which has custom +/-/*/etc.. defined, it'd be nice if you can do that directly in Python. E.g.
where that error is the current behavior but it would be nice if it instead returned:
I think I can probably implement this if you think you'd accept this functionality.
From a quick glance it looks like the way to proceed is to give the jlwrap object
__add__
,__mul__
, etc... via some mechanism or another somewhere near https://github.com/JuliaPy/PyCall.jl/blob/master/src/pytype.jl#L379, either by adding to that if-clause, or something else. Am I on the right track?The text was updated successfully, but these errors were encountered: