Skip to content

Commit

Permalink
Correct bug in duplicate keys detection; introduce test that catches …
Browse files Browse the repository at this point in the history
…the bug
  • Loading branch information
nrontsis committed Nov 24, 2022
1 parent 7bc3561 commit 5f92105
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Base.cat(inputs::ComponentArray...; dims::Int)
combined_data = cat(getdata.(inputs)...; dims=dims)
axes_to_merge = [(getaxes(i)..., FlatAxis())[dims] for i in inputs]
rest_axes = [getaxes(i)[1:end .!= dims] for i in inputs]
no_duplicate_keys = (length(inputs) == 1 || isempty(intersect(keys.(axes_to_merge)...)))
no_duplicate_keys = (length(inputs) == 1 || allunique(vcat(collect.(keys.(axes_to_merge))...)))
if no_duplicate_keys && length(Set(rest_axes)) == 1
offsets = (0, cumsum(size.(inputs, dims))[1:(end - 1)]...)
merged_axis = Axis(merge(indexmap.(reindex.(axes_to_merge, offsets))...))
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ end
@test ldiv!(tempmat, lu(cmat + I), cmat) isa ComponentMatrix
@test ldiv!(getdata(tempmat), lu(cmat + I), cmat) isa AbstractMatrix

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

0 comments on commit 5f92105

Please sign in to comment.