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

make parentindices consistent with Base #250

Merged
merged 2 commits into from
Oct 14, 2022
Merged

Conversation

aplavin
Copy link
Member

@aplavin aplavin commented Oct 3, 2022

In Julia, the parentindices function returns the indices of a view in its parent array: parentindices(view(A, I)) == (I,). However, for StructArray views this function always returned consecutive indices ignoring the view:

julia> A = [1+2im, 3+4im]
2-element Vector{Complex{Int64}}:
 1 + 2im
 3 + 4im

julia> SA = StructArray(A)
2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}:
 1 + 2im
 3 + 4im

julia> parentindices(view(A, [2]))
([2],)

julia> parentindices(view(SA, [2]))
(Base.OneTo(1),)

This PR fixes the above, so that parentindices(view(SA, [2])) == parentindices(view(A, [2])) == ([2],).

@aplavin
Copy link
Member Author

aplavin commented Oct 3, 2022

If the implementation is generally fine, I'll fix the allequal error on 1.6.

@piever
Copy link
Collaborator

piever commented Oct 10, 2022

Seems correct to me! Instead of allequal, probably the easiest is to copy the technique used to check equal axes in the constructor

map(tail(c)) do ci
(it might even be worth it to factor it out).

@aplavin
Copy link
Member Author

aplavin commented Oct 13, 2022

fixed, and added more tests
should be ready to merge

@piever piever merged commit 0933432 into JuliaArrays:master Oct 14, 2022
@aplavin aplavin deleted the pind branch October 15, 2022 06:41
@aplavin
Copy link
Member Author

aplavin commented Oct 17, 2022

@piever this PR and several others were merged, but don't seem available in the registered version. Could you please tag a 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.

2 participants