Skip to content

Commit 03d91ad

Browse files
author
Michael Abbott
committed
explicitly Compat.stride
1 parent 5ae5f12 commit 03d91ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Compat.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,13 @@ end
418418
# and also https://github.com/JuliaLang/julia/pull/29135 -> Julia 1.5
419419
if VERSION < v"1.6.0-DEV.323"
420420

421-
# This is Int not Integer, to be more strict than an existing method:
422-
function stride(A::AbstractArray, k::Int)
421+
# Compat.stride not Base.stride, so as not to overwrite the method, and not to create ambiguities:
422+
function stride(A::AbstractArray, k::Integer)
423423
st = strides(A)
424424
k ndims(A) && return st[k]
425425
return sum(st .* size(A))
426426
end
427+
stride(A,k) = Base.stride(A,k) # Fall-through for other methods.
427428

428429
# These were first defined for Adjoint{...,StridedVector} etc in #29135
429430
Base.strides(A::Adjoint{<:Real, <:AbstractVector}) = (stride(A.parent, 2), stride(A.parent, 1))

0 commit comments

Comments
 (0)