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
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
Next Next commit
Fix offsets computation
  • Loading branch information
nrontsis committed Oct 27, 2022
commit 419105fdc0f8b1d5aebf44e066a13757df3d0590
2 changes: 1 addition & 1 deletion src/array_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Base.cat(inputs::ComponentArray...; dims::Int)
rest_axes = [getaxes(i)[1:end .!= dims] for i in inputs]
no_duplicate_keys = (length(inputs) == 1 || isempty(intersect(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 = cumsum(size.(inputs, 1) .- size(first(inputs), 1))
offsets = (0, cumsum(size.(inputs, dims))[1:(end - 1)]...)
merged_axis = Axis(merge(indexmap.(reindex.(axes_to_merge, offsets))...))
result_axes = (first(rest_axes)[1:(dims - 1)]..., merged_axis, first(rest_axes)[dims:end]...)
return ComponentArray(combined_data, result_axes...)
Expand Down