JunoLab / Juno.jl

MIT License
144 stars 23 forks source link

[BUG]: PyCall.jl doesn't convert pyobject to Julia array when run in Juno #591

Closed andreyzhitnikov closed 4 years ago

andreyzhitnikov commented 4 years ago

Details

Steps to reproduce

  1. in Juno: using PyCall np = pyimport("numpy") a= np.zeros(3)

a stays PyObject

2.In REPL: a= np.zeros(3) 3-element Array{Float64,1}: 0.0 0.0 0.0

aviatesk commented 4 years ago

I can't repro this (with PyCall@1.91.4)

using PyCall
const np = pyimport("numpy")
a = np.zeros(3) # => Vector{Float64} with 3 elements
cuihantao commented 4 years ago

@aviatesk I believe this bug still exists and can be reproduced with the following

using PyCall
const np = pyimport("numpy")
a = np.zeros(3)
b = Array(a)

a remains a PyObject and won't be converted to Array when debugging.

Package versions are as follows

  [c52e3926] Atom v0.12.15
  [e5e0dc1b] Juno v0.8.2
  [438e738f] PyCall v1.91.4
aviatesk commented 4 years ago

Could you try you can also reproduce this, e.g. using Debugger.jl or other JuliaInterpreter-based debugger ? I guess it's an upstream issue.

cuihantao commented 4 years ago

@aviatesk Thanks! It seems to be an upstream issue. I got it replicated in REPL using Debugger.jl. Going to post an issue to the upstream

using Debugger
using PyCall

julia> function test()
       np = pyimport("numpy")
       a = np.zeros(3)
       b = Array(a)
       end
test (generic function with 1 method)

julia> @enter test()
In test() at REPL[5]:2
 1  function test()
>2  np = pyimport("numpy")
 3  a = np.zeros(3)
 4  b = Array(a)
 5  end

About to run: (PyCall.pyimport)("numpy")
1|debug> n
In test() at REPL[5]:2
 1  function test()
 2  np = pyimport("numpy")
>3  a = np.zeros(3)
 4  b = Array(a)
 5  end

About to run: <(getproperty)(PyObject <module 'numpy' from '/home/hcui7/miniconda3/envs/aa/lib/python3.7/site-packag...>
1|debug> n
In test() at REPL[5]:2
 1  function test()
 2  np = pyimport("numpy")
 3  a = np.zeros(3)
>4  b = Array(a)
 5  end

About to run: (Array)(PyObject array([0., 0., 0.]))
1|debug> n
ERROR: MethodError: no method matching Array(::PyObject)
Closest candidates are:
  Array(::LinearAlgebra.SymTridiagonal) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/tridiag.jl:111
  Array(::LinearAlgebra.Tridiagonal) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/tridiag.jl:528
  Array(::LinearAlgebra.AbstractTriangular) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/triangular.jl:162
  ...
Stacktrace:
 [1] test() at REPL[5]:4

julia>
aviatesk commented 4 years ago

cool, here is where you want to post it: https://github.com/JuliaDebug/JuliaInterpreter.jl/issues