Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/structarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ map(c -> c[I...], Tuple(cols))

Base.@propagate_inbounds Base.getindex(x::StructArray, I...) = _getindex(x, to_indices(x, I)...)

Base.getindex(s::StructArray{<:NamedTuple, <:Any, <:NamedTuple}, keys::Tuple{Vararg{Symbol}}) = StructArray(components(s)[keys])

Base.@propagate_inbounds function _getindex(x::StructArray{T}, I::Vararg{Int}) where {T}
cols = components(x)
@boundscheck checkbounds(x, I...)
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Base.convert(::Type{Millimeters}, x::Meters) = Millimeters(x.x*1000)

s = StructArray(a=1:5)
@test s[2:3].a === 2:3

t2 = StructArray(x = [1, 2], y = [3, 4], z = [5, 6])
@test t2[(:x, :y)] == StructArray(x = [1, 2], y = [3, 4])
end

@testset "eltype conversion" begin
Expand Down
Loading