Skip to content

Commit

Permalink
tests dimension mismatch in cat as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Jul 27, 2023
1 parent f0e4802 commit 95e112b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function Base._cat(catdim::Union{Int,DimOrDimType}, Xin::AbstractDimArray...)
end
function _cat(catdims::Tuple, A1::AbstractDimArray, As::AbstractDimArray...)
Xin = (A1, As...)
comparedims(map(x -> otherdims(x, catdims), Xin)...)
comparedims(map(x -> otherdims(x, catdims), Xin)...; val=true)
newcatdims = map(catdims) do catdim
if all(x -> hasdim(x, catdim), Xin)
# We concatenate an existing dimension
Expand Down
2 changes: 2 additions & 0 deletions test/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,11 @@ end
da = DimArray(a, (X(4.0:5.0), Y(6.0:8.0)))
b = [7 8 9; 10 11 12]
db = DimArray(b, (X(6.0:7.0), Y(6.0:8.0)))
dc = DimArray(b, (X(6.0:7.0), Y(10.0:12.0)))

@testset "Regular Sampled" begin
@test cat(da, db; dims=X()) == [1 2 3; 4 5 6; 7 8 9; 10 11 12]
@test_throws DimensionMismatch cat(da, dc; dims=X())
testdims = (X(Sampled([4.0, 5.0, 6.0, 7.0], ForwardOrdered(), Regular(1.0), Points(), NoMetadata())),
Y(Sampled(6.0:8.0, ForwardOrdered(), Regular(1.0), Points(), NoMetadata())))
@test cat(da, db; dims=(X(),)) == cat(da, db; dims=X()) == cat(da, db; dims=X) ==
Expand Down

0 comments on commit 95e112b

Please sign in to comment.