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

Extend KeepIndex to Vector indices #243

Open
qua4tre opened this issue Feb 16, 2024 · 1 comment
Open

Extend KeepIndex to Vector indices #243

qua4tre opened this issue Feb 16, 2024 · 1 comment

Comments

@qua4tre
Copy link

qua4tre commented Feb 16, 2024

Using an example from the documentation:

julia> ca = ComponentArray(a=5, b=[4, 1], c=(a=2, b=[6, 30]))
ComponentVector{Int64}(a = 5, b = [4, 1], c = (a = 2, b = [6, 30]))

julia> ca[KeepIndex(:b)]
ComponentVector{Int64}(b = [4, 1])

julia> ca[KeepIndex(1)]
ComponentVector{Int64}(a = 5)

julia> ca[KeepIndex(2:3)]
ComponentVector{Int64}(b = [4, 1])

julia> ca[KeepIndex([2,3])]
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type Vector{Int64}

How hard would it be to extend the KeepIndex functionality to more general types of indices?

@jonniedie
Copy link
Collaborator

Pretty tough if it needs to be performant. KeepIndex puts the indices into a type parameter so it can do the indexing type-stably. That wouldn't be possible with a Vector because it is not an isbits type, so it can't be held as a type parameter. But we could probably make this work with a SVector from StaticArrays, but it might be quite a bit of effort to get that working.

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

No branches or pull requests

2 participants