Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Sep 20, 2020

This is a patchwork of fixes that address a couple of common cases encountered while indexing with offset axes.

Now

julia> a = OffsetVector(3:4, 10:11)
3:4 with indices 10:11

julia> ax = Base.IdentityUnitRange(10:11)
Base.IdentityUnitRange(10:11)

julia> a[ax]
3:4 with indices 10:11

julia> axes(a[ax]) == axes(ax)
true

julia> ax = OffsetArrays.IdOffsetRange(5:6, 5)
OffsetArrays.IdOffsetRange(10:11)

julia> a[ax]
3:4 with indices 6:7

julia> axes(a[ax]) == axes(ax)
true

This is not really a proper fix, as ideally we would want to return an OffsetVector when an OffsetRange is indexed using an arbitrary AbstractUnitRange. However that might be too breaking, so as of now I suppose this will have to do.

Fixes #155

@codecov
Copy link

codecov bot commented Sep 20, 2020

Codecov Report

Merging #156 into master will increase coverage by 0.83%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #156      +/-   ##
==========================================
+ Coverage   94.02%   94.86%   +0.83%     
==========================================
  Files           2        2              
  Lines         251      253       +2     
==========================================
+ Hits          236      240       +4     
+ Misses         15       13       -2     
Impacted Files Coverage Δ
src/OffsetArrays.jl 95.69% <100.00%> (+1.00%) ⬆️

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 dc867d5...96aa2c7. Read the comment docs.

@jishnub jishnub merged commit f50ebe9 into JuliaArrays:master Sep 21, 2020
@jishnub jishnub deleted the idempotencefix branch January 17, 2021 08:57
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.

Indexing is not idempotent using Base.IdentityUnitRange

1 participant