Skip to content
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

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

Closed
andreyzhitnikov opened this issue May 25, 2020 · 5 comments
Labels

Comments

@andreyzhitnikov
Copy link

andreyzhitnikov commented May 25, 2020

Details

  • Atom version: 1.47.0
  • Julia version:1.4.1
  • OS:Ubuntu 18.4
  • Package versions:
    • Atom.jl: v0.12.11
    • julia-client: 0.12.5
    • ink: 0.12.4

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
Copy link
Member

aviatesk commented Jun 18, 2020

I can't repro this (with [email protected])

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

@cuihantao
Copy link

cuihantao commented Jul 2, 2020

@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
Copy link
Member

aviatesk commented Jul 3, 2020

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
Copy link

cuihantao commented Jul 3, 2020

@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
Copy link
Member

aviatesk commented Jul 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants