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

Indexing OneTo with IdentityUnitRange preserves axes #40997

Merged
merged 1 commit into from
May 31, 2021

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented May 29, 2021

On master:

julia> Base.OneTo(10)[Base.IdentityUnitRange(2:7)]
2:7

After this PR:

julia> Base.OneTo(10)[Base.IdentityUnitRange(2:7)]
Base.IdentityUnitRange(2:7)

Copy link
Sponsor 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.

I understand that this cooperates with #40660 and OffsetArrays for more consistent result:

using OffsetArrays

inds = Base.IdentityUnitRange(2:7);

(1:7)[inds] |> axes
# (OffsetArrays.IdOffsetRange(values=2:7, indices=2:7),)

collect(1:7)[inds] |> axes
# (OffsetArrays.IdOffsetRange(values=2:7, indices=2:7),)

# fixes the inconsistency in master
Base.OneTo(7)[inds] |> axes
# master: (Base.OneTo(6),)
# PR: (Base.IdentityUnitRange(2:7),)

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.

3 participants