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
Describe the bug
I would like to get a pointer to a view of a PyArray
julia> using PythonCall
julia> x =view(PyArray(UInt8[1,2,3]), 1:2)
2-element view(::PyArray{UInt8, 1}, 1:2) with eltype UInt8:
0x01
0x02
julia> y = Base.cconvert(Ptr{UInt8}, x)
2-element view(::PyArray{UInt8, 1}, 1:2) with eltype UInt8:
0x01
0x02
julia> Base.unsafe_convert(Ptr{UInt8}, y)
ERROR: MethodError: no method matching elsize(::Type{PyArray{UInt8, 1, true, true, UInt8}})
The function `elsize` exists, but no method is defined for this combination of argument types.
Closest candidates are:
elsize(::Type{Union{}}, Any...)
@ Base array.jl:233
elsize(::Type{<:LinearAlgebra.Adjoint{<:Real, P}}) where P<:(AbstractVecOrMat)
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.2+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/adjtrans.jl:355
elsize(::Type{A}) where {T, A<:(Array{T})}
@ Base array.jl:225
...
Stacktrace:
[1] elsize(A::PyArray{UInt8, 1, true, true, UInt8})
@ Base ./abstractarray.jl:257
[2] _memory_offset(x::PyArray{UInt8, 1, true, true, UInt8}, I::Int64)
@ Base ./abstractarray.jl:1239
[3] unsafe_convert(::Type{Ptr{…}}, V::SubArray{UInt8, 1, PyArray{…}, Tuple{…}, true})
@ Base ./reshapedarray.jl:329
[4] top-level scope
@ REPL[71]:1
Some type information was truncated. Use `show(err)` to see complete types.
Your system
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 × Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
PythonCall v0.9.23
The text was updated successfully, but these errors were encountered:
Affects: PythonCall
Describe the bug
I would like to get a pointer to a view of a
PyArray
Your system
The text was updated successfully, but these errors were encountered: