Skip to content
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

Fix error in validating complex row-first hvncat #45365

Merged
merged 3 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2396,14 +2396,17 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as
# validate shapes for lowest level of concatenation
d = findfirst(>(1), dims)
if d !== nothing # all dims are 1
if row_first && d < 3
d = d == 1 ? 2 : 1
end
nblocks = length(as) ÷ dims[d]
for b ∈ 1:nblocks
offset = ((b - 1) * dims[d])
startelementi = offset + 1
for i ∈ offset .+ (2:dims[d])
for dd ∈ 1:N
dd == d && continue
if size(as[startelementi], dd) != size(as[i], dd)
if cat_size(as[startelementi], dd) != cat_size(as[i], dd)
throw(ArgumentError("incompatible shape in element $i"))
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,8 @@ using Base: typed_hvncat
# Issue 43933 - semicolon precedence mistake should produce an error
@test_throws ArgumentError [[1 1]; 2 ;; 3 ; [3 4]]
@test_throws ArgumentError [[1 ;;; 1]; 2 ;;; 3 ; [3 ;;; 4]]

@test [[1 2; 3 4] [5; 6]; [7 8] 9;;;] == [1 2 5; 3 4 6; 7 8 9;;;]
end

@testset "keepat!" begin
Expand Down