StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

move to modern indexing style

Open Moelf opened this issue 3 years ago • 5 comments

Moelf avatar May 16 '22 19:05 Moelf

check #722 too

Moelf avatar May 16 '22 19:05 Moelf

Compiler should infer inbounds when using each index

Moelf avatar May 16 '22 21:05 Moelf

after some testing, zip() is as slow as eachindex(a, b) without @inbounds

I suggest keep using eachindex(a, b) but also add @inbounds

Moelf avatar May 16 '22 22:05 Moelf

on the master branch of Julia, the @inbounds is inferred from for i in eachindex(a, b) as expected.

and I don't understand the CI error on nightly

Moelf avatar May 16 '22 22:05 Moelf

Seems like the PR is mainly missing tests, e.g., with OffsetArrays? (Of course, there are other possible improvements discussed in some comments above but in my opinion they could go into separate PRs since this PR is already a clear improvement for arrays with non-standard indices.)

devmotion avatar May 17 '22 11:05 devmotion

@Moelf could we wrap up this PR? It looks almost ready to merge and I want to end all the negative press from StatsBase's frequent @inbounds errors.

(By the way, does eachindex still not automatically elide bounds checking?)

ParadaCarleton avatar Aug 22 '23 18:08 ParadaCarleton

what's the desired action? do we want to use zip or @inbounds?

Moelf avatar Aug 22 '23 18:08 Moelf

I'm happy with @inbounds, as long as eachindex is being used. If we want to fix that later that's fine, but for now we just need to fix the bugs.

ParadaCarleton avatar Aug 22 '23 19:08 ParadaCarleton

oh, but then it's already fixed on master, closing now

Moelf avatar Aug 22 '23 19:08 Moelf