Skip to content

Fix *cat inconsistencies #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Correct bug in duplicate keys detection; introduce test that catches …
…the bug
  • Loading branch information
nrontsis committed Nov 24, 2022
commit 5f92105e49106807082fa9054ff49e4117b78cc6
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the extra check length(Set(rest_axes)) == 1 that was not in place in the previous implementation.

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