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

Can't index component array with shaped components with subset of keys #256

Closed
marius311 opened this issue Apr 7, 2024 · 2 comments · Fixed by #259
Closed

Can't index component array with shaped components with subset of keys #256

marius311 opened this issue Apr 7, 2024 · 2 comments · Fixed by #259

Comments

@marius311
Copy link

Would be convenient if this worked and returned a new ComponentArray with just the x and y components, ComponentArrays 0.15.11:

julia> using ComponentArrays

julia> c = ComponentVector(x=rand(2,2), y=rand(3), z=4)
ComponentVector{Float64}(x = [0.08932677188438709 0.2039248385682888; 0.7932786495449815 0.9448910346464564], y = [0.8857236834484066, 0.3657104827001233, 0.7234530317203763], z = 4.0)

julia> c[[:x,:y]]
ERROR: MethodError: no method matching _maybe_view_axis(::UnitRange{Int64}, ::ShapedAxis{(2, 2)})

Fwiw this works with scalar components eg if c = ComponentVector(x=2, y=3, z=4)

@jonniedie
Copy link
Owner

It looks like this is specifically only broken with matrices and higher-dimensional array components because of a missing method for _maybe_view_axis(::Any, ::ShapedAxis). Let me see if it's a pretty straightforward fix...

@jonniedie
Copy link
Owner

Fix ended up being pretty simple. We were doing ::Axis for that method when it really needed to be ::AbstractAxis.

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 a pull request may close this issue.

2 participants