Skip to content

Commit

Permalink
indexing of arrays of arrays
Browse files Browse the repository at this point in the history
closes #83
  • Loading branch information
mcabbott committed Oct 3, 2021
1 parent 853bd30 commit 86fdfb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ for (get_or_view, key_get, maybe_copy) in [
inds = to_indices(A, raw_inds)
@boundscheck checkbounds(parent(A), inds...)
data = @inbounds $get_or_view(parent(A), inds...)
data isa AbstractArray || return data # scalar output
inds isa Tuple{Vararg{Integer}} && return data # scalar output

raw_keys = $key_get(axiskeys(A), inds)
raw_keys === () && return data # things like A[A .> 0]
Expand Down
4 changes: 4 additions & 0 deletions test/_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ using Test, AxisKeys
@test_throws Exception wrapdims(rand(5), ['a','b','c'])
@test_throws Exception KeyedArray(rand(5), ['a','b','c'])

G = KeyedArray([[1,2], [3,4], [5,6]], 'α':'γ') # array of arrays, issue 83
@test G[end] == [5,6]
@test axiskeys(G') == (1:1, 'α':'γ')
@test begin G('α',:) .= Ref([7,8]); G[1] == [7,8] end # trailing colon still OK here
end
@testset "selectors" begin

Expand Down

0 comments on commit 86fdfb2

Please sign in to comment.