diff --git a/src/DAT/broadcast.jl b/src/DAT/broadcast.jl index 4ab4e94c..4b64d36e 100644 --- a/src/DAT/broadcast.jl +++ b/src/DAT/broadcast.jl @@ -17,14 +17,10 @@ function Base.materialize(bc::Broadcast.Broadcasted{XStyle}) args2 = map(arg -> arg isa Broadcast.Broadcasted ? Base.materialize(arg) : arg, bc.args) args2 = map(to_yax, args2) # determine output type by calling `eltype` on a dummy function call - dummy_args = map(a -> first(a.data), args2) - outtype = typeof(bc.f(dummy_args...)) + intypes = (eltype.(args2)...,) + @debug intypes + outtypes = Base.return_types(bc.f, intypes) + outtype = Base.promote_type(outtypes...) + @debug outtype return xmap(XFunction(bc.f; inplace=false), args2..., output=XOutput(; outtype)) -end -function Base.materialize!(bc::Broadcast.Broadcasted{XStyle}) - args2 = map(arg -> arg isa Broadcast.Broadcasted ? Base.materialize(arg) : arg, bc.args) - args2 = map(to_yax, args2) - dummy_args = map(a -> first(a.data), args2) - outtype = typeof(bc.f(dummy_args...)) - return xmap(XFunction(bc.f; inplace=true), args2..., output=XOutput(; outtype)) end \ No newline at end of file diff --git a/test/DAT/broadcast.jl b/test/DAT/broadcast.jl index 93d1074d..4a0214b6 100644 --- a/test/DAT/broadcast.jl +++ b/test/DAT/broadcast.jl @@ -60,4 +60,12 @@ a, b, c = sample_arrays() xscalar = a .* 3 .+ 1 @test all(xscalar[:] .== 4.0) @test isa(a .+ b, YAXArray) +end + +@testset "missing handling" begin + am = YAXArray([missing 1 ; 1 2]) + aeq = am .== am + @test eltype(aeq) == Union{Missing, Bool} + @test ismissing(aeq[1,1]) + @test aeq[1,2] end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index dd8f12bd..e9b26177 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,6 +17,7 @@ include("Datasets/datasets.jl") include("DAT/PickAxisArray.jl") include("DAT/MovingWindow.jl") +include("DAT/broadcast.jl") include("DAT/tablestats.jl") include("DAT/mapcube.jl") include("DAT/xmap.jl")