Skip to content

Commit 17450eb

Browse files
committed
Infer outputtype by return_types
1 parent 7ab2a92 commit 17450eb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/DAT/broadcast.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ function Base.materialize(bc::Broadcast.Broadcasted{XStyle})
1717
args2 = map(arg -> arg isa Broadcast.Broadcasted ? Base.materialize(arg) : arg, bc.args)
1818
args2 = map(to_yax, args2)
1919
# determine output type by calling `eltype` on a dummy function call
20-
dummy_args = map(a -> first(a.data), args2)
21-
outtype = typeof(bc.f(dummy_args...))
20+
intypes = (eltype.(args2)...,)
21+
@debug intypes
22+
outtypes = Base.return_types(bc.f, intypes)
23+
outtype = Union{outtypes...}
24+
@debug outtype
2225
return xmap(XFunction(bc.f; inplace=false), args2..., output=XOutput(; outtype))
2326
end
2427
function Base.materialize!(bc::Broadcast.Broadcasted{XStyle})

test/DAT/broadcast.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,12 @@ a, b, c = sample_arrays()
6060
xscalar = a .* 3 .+ 1
6161
@test all(xscalar[:] .== 4.0)
6262
@test isa(a .+ b, YAXArray)
63+
end
64+
65+
@testset "missing handling" begin
66+
am = YAXArray([missing 1 ; 1 2])
67+
aeq = am .== am
68+
@test eltype(aeq) == Union{Missing, Bool}
69+
@test ismissing(aeq[1,1])
70+
@test aeq[1,2]
6371
end

0 commit comments

Comments
 (0)