Skip to content

Commit db54eaf

Browse files
author
Christopher Rowley
committed
Simplify contiguous PyArray Cartesian offsets
1 parent 55d83e7 commit db54eaf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/Wrap/PyArray.jl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,10 @@ function pyarray_offset(x::PyArray{T,N,F}, i::Int) where {T,N,F}
639639
end
640640

641641
function pyarray_offset(x::PyArray{T,N,F}, i::Vararg{Int,N}) where {T,N,F}
642-
# Strides from the size make the unit first stride a compile-time constant, so loops vectorise.
642+
# Make the unit first stride a compile-time constant, so loops vectorise.
643643
# Also matters for N == 1, where this method is picked over `pyarray_offset(x, i::Int)`.
644-
if (:contiguous in F)
645-
sum((i .- 1) .* Utils.size_to_fstrides(sizeof(pyarray_get_R(T)), x.size))
644+
if N >= 1 && (:contiguous in F)
645+
sum((i .- 1) .* (sizeof(pyarray_get_R(T)), x.strides[2:end]...))
646646
else
647647
sum((i .- 1) .* x.strides)
648648
end

0 commit comments

Comments
 (0)