Skip to content

Commit 5f92105

Browse files
committed
Correct bug in duplicate keys detection; introduce test that catches the bug
1 parent 7bc3561 commit 5f92105

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/array_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Base.cat(inputs::ComponentArray...; dims::Int)
2020
combined_data = cat(getdata.(inputs)...; dims=dims)
2121
axes_to_merge = [(getaxes(i)..., FlatAxis())[dims] for i in inputs]
2222
rest_axes = [getaxes(i)[1:end .!= dims] for i in inputs]
23-
no_duplicate_keys = (length(inputs) == 1 || isempty(intersect(keys.(axes_to_merge)...)))
23+
no_duplicate_keys = (length(inputs) == 1 || allunique(vcat(collect.(keys.(axes_to_merge))...)))
2424
if no_duplicate_keys && length(Set(rest_axes)) == 1
2525
offsets = (0, cumsum(size.(inputs, dims))[1:(end - 1)]...)
2626
merged_axis = Axis(merge(indexmap.(reindex.(axes_to_merge, offsets))...))

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ end
482482
@test ldiv!(tempmat, lu(cmat + I), cmat) isa ComponentMatrix
483483
@test ldiv!(getdata(tempmat), lu(cmat + I), cmat) isa AbstractMatrix
484484

485+
@test !(vcat(ca, ca2, ca) isa ComponentVector)
485486
for n in 1:3 # Issue 168 cats (on more than one) ComponentArrays
486487
vca2 = vcat(repeat([ca2'], n)...)
487488
hca2 = hcat(repeat([ca2], n)...)

0 commit comments

Comments
 (0)