Skip to content

Commit 06724c6

Browse files
committed
Add handling in cat for non-numeric element types
1 parent 7bca709 commit 06724c6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/fillcat.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ function Base.cat_t(::Type{T}, fs::Fill...; dims) where T
77

88
# When dims is a tuple the output gets zero padded and we can't use a Fill unless it is all zeros
99
# There might be some cases when it does not get padded which are not considered here
10-
allvals[] !== zero(T) && sum(catdims) > 1 && return Base._cat_t(dims, T, fs...)
10+
11+
if sum(catdims) > 1
12+
allvals[] isa Number || return Base._cat_t(dims, T, fs...)
13+
allvals[] !== zero(T) && return Base._cat_t(dims, T, fs...)
14+
end
1115

1216
shape = cat_shape_fill(catdims, fs)
1317
return Fill(convert(T, fs[1].value), shape)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,10 @@ end
12541254
@test res isa Fill
12551255
@test res == cat(fill(1.0, s), fill(1, s); dims=dims)
12561256

1257+
res = cat(Fill(:a, s), Fill(:a, s); dims=dims)
1258+
@test res isa Fill
1259+
@test res == cat(fill(:a, s), fill(:a, s);dims=dims)
1260+
12571261
@test cat(Fill(1, s), Fill(2, s);dims=dims) == cat(fill(1, s), fill(2, s);dims=dims)
12581262
end
12591263
@testset "Dim $dims" for dims in (

0 commit comments

Comments
 (0)