Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/array_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ Base.@propagate_inbounds Base.maybeview(x::ComponentArray, idx...) = _getindex(B
inds = map(i -> i.idx, ci)
axs = map(i -> i.ax, ci)
axs = remove_nulls(axs...)
return :(ComponentArray(index_fun(getdata(x), $inds...), $axs...))
if isa(axs, Tuple{})
return :(index_fun(getdata(x), $inds...))
else
return :(ComponentArray(index_fun(getdata(x), $inds...), $axs...))
end
end

@generated function _setindex!(x::ComponentArray, v, idx...)
Expand Down
2 changes: 1 addition & 1 deletion src/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function Base.getindex(ax::AbstractAxis, syms::Union{NTuple{N,Symbol}, <:Abstrac
_maybe_view_axis(first_index:last_index, ax)
end
new_ax = Axis(NamedTuple(syms .=> new_axs))
return ComponentIndex(reduce(vcat, inds), new_ax)
return ComponentIndex(vcat(inds...), new_ax)
end

_maybe_view_axis(inds, ax::Axis) = ViewAxis(inds, ax)
Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ end
@test ca.c == ComponentArray(c)
@test ca2.b[1].a.a == 20.0

@test ca[:a] == ca["a"] == ca.a
@test ca[:a] == ca["a"] == ca.a == ca[[:a]][1]
@test ca[[:a]] isa ComponentVector # Issue 175
@test ca[Symbol[]] == Float64[] # Issue 174
@test length(ca[()]) == 0 # Issue #174
@test ca[:b] == ca["b"] == ca.b
@test ca[:c] == ca["c"] == ca.c

Expand Down