PyCall.jl
PyCall.jl copied to clipboard
Numpy r_ / c_ / ix_ issues
The handy numpy convenience "methods" r_ / c_ / ix_ (using bracket syntax) don't work as expected:
julia> using PyCall; @pyimport numpy as np
julia> np.r_[1, 3, 5]
3-element Array{Int32,1}:
0
2
4
This should return a numpy array with [1, 3, 5] as elements (see bottom for Python example)
Also, the following typical r_ usage gives an error:
julia> np.r_[1:3]
ERROR: MethodError: no method matching getindex(::PyObject, ::UnitRange{Int64})
Closest candidates are:
getindex(::PyObject, ::T) where T<:Union{AbstractString, Symbol} at C:\Users\joerg\.julia\packages\PyCall\BcTLp\src\PyCall.jl:337
getindex(::PyObject, ::Integer) at deprecated.jl:70
getindex(::PyObject, ::Integer, ::Integer) at deprecated.jl:70
...
Stacktrace:
[1] top-level scope at REPL[35]:1
Version information:
julia> using Pkg; Pkg.installed()["PyCall"]
v"1.92.1"
julia> using PyCall; @pyimport numpy as np
julia> np.__version__
"1.19.1"
julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Same in Python:
In [3]: np.r_[1, 3, 5]
Out[3]: array([1, 3, 5], dtype=int32)
In [4]: np.r_[1:3]
Out[4]: array([1, 2])