Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #133: compute_offset1 for an IdOffsetRange axis #134

Closed
wants to merge 1 commit into from

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Aug 24, 2020

Now

julia> a12 = zeros(3:8, 3:4);

julia> r = OffsetArrays.IdOffsetRange(Base.OneTo(3), 5)
6:8

julia> a12[r, 4] .= 3
3-element view(OffsetArray(::Array{Float64,2}, 3:8, 3:4), 6:8, 4) with eltype Float64 with indices 6:8:
 3.0
 3.0
 3.0

julia> a12
6×2 OffsetArray(::Array{Float64,2}, 3:8, 3:4) with eltype Float64 with indices 3:8×3:4:
 0.0  0.0
 0.0  0.0
 0.0  0.0
 0.0  3.0
 0.0  3.0
 0.0  3.0

@codecov
Copy link

codecov bot commented Aug 24, 2020

Codecov Report

Merging #134 into master will increase coverage by 2.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   84.26%   86.29%   +2.03%     
==========================================
  Files           2        2              
  Lines         197      197              
==========================================
+ Hits          166      170       +4     
+ Misses         31       27       -4     
Impacted Files Coverage Δ
src/axes.jl 85.36% <ø> (+9.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6fae67...cb4a803. Read the comment docs.

@jishnub
Copy link
Member Author

jishnub commented Aug 24, 2020

Fixes #133

Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently you've figured out what it should be! I myself is still a little lost here, approve because the test cases are good. It would be better if @timholy can take a look before I merge this.

@jishnub
Copy link
Member Author

jishnub commented Aug 26, 2020

This is similar to an issue in Base that I had described here, the fix is this:

compute_offset1(parent, stride1::Integer, dims, inds::Tuple{AbstractRange}, I::Tuple) =
    (@_inline_meta; compute_linindex(parent, I) - stride1*first(axes1(inds[1]))) # potentially index-offsetting case

This is equivalent to our fix here, as Base.axes1(r) == r for an IdOffsetRange.

@mbauman
Copy link
Member

mbauman commented Aug 26, 2020

I'd hope that this method can be deleted entirely after JuliaLang/julia#37204 is merged/backported — those base behaviors should be correct (but this fix makes sense to help ensure correctness on older versions).

johnnychen94 added a commit that referenced this pull request Aug 29, 2020
Julia < 1.6 still need this for correctness

closes #100
closes #133
closes #134
@jishnub jishnub deleted the compute_offset1 branch August 30, 2020 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants