Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c4bda2e

Browse files
author
Andy Ferris
committedJul 7, 2018
Make accumulate! compatible with offset indices
1 parent de75b4d commit c4bda2e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎base/accumulate.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ function _accumulate1!(op, B, v1, A::AbstractVector, dim::Integer)
383383
inds = LinearIndices(A)
384384
inds == LinearIndices(B) || throw(DimensionMismatch("LinearIndices of A and B don't match"))
385385
dim > 1 && return copyto!(B, A)
386-
i1 = inds[1]
386+
i1 = first(inds)
387387
cur_val = v1
388388
B[i1] = cur_val
389-
@inbounds for i in inds[2:end]
389+
@inbounds for i in inds[2:end] # Range getindex of offset slices is inconsistent with scalar indexing of offset slices
390390
cur_val = op(cur_val, A[i])
391391
B[i] = cur_val
392392
end

0 commit comments

Comments
 (0)
Please sign in to comment.