Skip to content

Commit ecdeb43

Browse files
committed
Implement try_strides
1 parent beec1ec commit ecdeb43

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Wrap/PyArray.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,17 @@ Base.strides(x::PyArray{T,N,M,L,R}) where {T,N,M,L,R} =
636636
error("strides are not a multiple of element size")
637637
end
638638

639+
@static if isdefined(Base, :try_strides)
640+
Base.try_strides(x::PyArray{T,N,M,L,T}) where {T,N,M,L} =
641+
if all(mod.(x.strides, sizeof(T)) .== 0)
642+
div.(x.strides, sizeof(T))
643+
else
644+
nothing
645+
end
646+
Base.is_ptr_loadable(x::PyArray{T,N,M,L,T}) where {T,N,M,L} = true
647+
Base.is_ptr_storable(x::PyArray{T,N,M,L,T}) where {T,N,M,L} = Utils.ismutablearray(x)
648+
end
649+
639650
function Base.showarg(io::IO, x::PyArray{T,N}, toplevel::Bool) where {T,N}
640651
toplevel || print(io, "::")
641652
print(io, "PyArray{")

0 commit comments

Comments
 (0)