JuliaPy / JuliaPy/PyCall.jl

strides is deprecated

Abierto
#555 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
1.5k
Forks
186
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

On 0.7, I can pass a reshaped range to PyCall

```
julia> np.sin(reshape(1:4, 2,2))
┌ Warning: The default `strides(a::AbstractArray)` implementation is deprecated for general arrays.
│ Specialize `strides(::Base.ReshapedArray)` if `Base.ReshapedArray` indeed uses a strided representation in memory.
│ Warning: inappropriately implementing this method for an array type that does not use strided
│ storage may lead to incorrect results or segfaults.
│ caller = stride at abstractarray.jl:350 [inlined]
└ @ Core ./abstractarray.jl:350
┌ Warning: The default `strides(a::AbstractArray)` implementation is deprecated for general arrays.
│ Specialize `strides(::Base.ReshapedArray)` if `Base.ReshapedArray` indeed uses a strided representation in memory.
│ Warning: inappropriately implementing this method for an array type that does not use strided
│ storage may lead to incorrect results or segfaults.
│ caller = stride at abstractarray.jl:350 [inlined]
└ @ Core ./abstractarray.jl:350
2×2 Array{Float64,2}:
0.841471 0.14112
0.909297 -0.756802
```

On 1.0, it's

```
ERROR: MethodError: no method matching strides(::Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}})
Closest candidates are:
strides(::SubArray) at subarray.jl:251
strides(::Base.CodeUnits) at strings/basic.jl:696
strides(::PermutedDimsArray{T,N,perm,iperm,AA} where AA<:AbstractArray where iperm) where {T, N, perm} at permuteddimsarray.jl:62
...
Stacktrace:
[1] stride(::Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}, ::Int64) at ./abstractarray.jl:342
[2] array2py(::Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}, ::Int64, ::Int64) at /home/cst-jean/.julia/packages/PyCall/rUul9/src/conversions.jl:305
[3] array2py(::Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}) at /home/cst-jean/.julia/packages/PyCall/rUul9/src/conversions.jl:325
[4] Type at /home/cst-jean/.julia/packages/PyCall/rUul9/src/conversions.jl:327 [inlined]
[5] macro expansion at /home/cst-jean/.julia/packages/PyCall/rUul9/src/exception.jl:84 [inlined]
[6] _pycall!(::PyObject, ::PyObject, ::Tuple{Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}}, ::Int64, ::Ptr{Nothing}) at /home/cst-jean/.julia/packages/PyCall/rUul9/src/pyfncall.jl:21
[7] #call#89 at /home/cst-jean/.julia/packages/PyCall/rUul9/src/pyfncall.jl:11 [inlined]
[8] (::PyObject)(::Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}) at /home/cst-jean/.julia/packages/PyCall/rUul9/src/pyfncall.jl:89
```

Is that a PyCall issue, or a base issue?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Reproduce the reshaped-range conversion shown in the issue on Julia 1.0, then inspect src/conversions.jl around array2py and the reported stride call. Compare PyCall's conversion path with Julia's strides(::Base.ReshapedArray) behavior to establish which side owns the incompatibility. Done means the example no longer raises the reported MethodError.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
julia, numpy, python
Área
backend, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
28/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.