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

use the first linear index instead of 1 for zero-argument getindex (redo #195) #196

Merged
merged 4 commits into from
Jan 29, 2021

Conversation

johnnychen94
Copy link
Member

JuliaLang/julia#39379 (comment)

Here's the root problem:

https://github.com/JuliaLang/julia/blob/69d24532980bda6db510b6d4b71f66e7ffff2e81/base/abstractarray.jl#L1196

Edit: This should probably be first(eachindex(A)) or somesuch.

Changes:

# master
OffsetArray([6], 2:2)[] # BoundsError
# this PR
OffsetArray([6], 2:2)[] == 6

Forked from JuliaLang/julia#39393, I'll wait until that gets merged.

Technically this is a breaking change, but since v1.5.2 was released yesterday, I'd see this as a bug fix and bump a patch version for it.

cc: @jishnub @mbauman

@codecov
Copy link

codecov bot commented Jan 26, 2021

Codecov Report

Merging #196 (043b26d) into master (1263513) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #196      +/-   ##
==========================================
- Coverage   98.93%   98.93%   -0.01%     
==========================================
  Files           5        5              
  Lines         283      281       -2     
==========================================
- Hits          280      278       -2     
  Misses          3        3              
Impacted Files Coverage Δ
src/axes.jl 100.00% <ø> (ø)
src/OffsetArrays.jl 98.93% <100.00%> (+<0.01%) ⬆️

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 1263513...2b82093. Read the comment docs.

@mbauman
Copy link
Member

mbauman commented Jan 26, 2021

Typically we don’t consider making errors functional breaking. This went in the perfect order to be nonbreaking: bug -> error -> functional. :)

@jishnub
Copy link
Member

jishnub commented Jan 26, 2021

Nice! I was not sure if A[] should behave like only(A) treating A as an iterator, or just deal with the indices as they're provided, in which case it had to work with A[1]. I chose the more conservative approach because this may be changed later in a non-breaking way, as in this PR.

This is the correct solution as it resolves the iterator/array debate. This works identically for both.

@johnnychen94 johnnychen94 merged commit 97cef1a into master Jan 29, 2021
@johnnychen94 johnnychen94 deleted the jc/0index branch January 29, 2021 09:01
@johnnychen94
Copy link
Member Author

johnnychen94 commented Jan 29, 2021

@jishnub I reverted the version bump here, hopefully, we can include #197 in OffsetArrays v1.5.3, too. I'll leave it to you to release the new version.

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