JuliaPy / JuliaPy/PyCall.jl

Numpy r_ / c_ / ix_ issues

Offen
#859 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
1.5k
Forks
186
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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])
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Reproduce the bracket-syntax cases for NumPy r_, c_, and ix_ through PyCall, then inspect the PyObject getindex methods referenced at PyCall.jl:337. Compare the Julia results with the supplied Python examples; done means these expressions return the expected NumPy arrays and range indexing no longer raises MethodError.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
julia, numpy
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.