LoopVectorization.jl
LoopVectorization.jl copied to clipboard
@turbo with passmissing?
I've been using FastBroadcast
and @turbo
to speed up broadcasting operations in DataFrames. However, missing values are quite common when you work with a DataFrame, and @turbo
throws an error in that case.
Is it possible to have something similar to passmissing
for @turbo
? This would be consistent with Base broadcast and as FastBroadcast works, which passes missing values when you broadcast.
using LoopVectorization, FastBroadcast
df = DataFrame(a = [1,missing,3])
@.. df.a .* df.a # this works
@turbo df.a .* df.a # this throws error
The error is:
ERROR: MethodError: no method matching vmaterialize!(::Vector{Union{Missing, Int64}},
::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(*),
Tuple{Vector{Union{Missing, Int64}}, Vector{Union{Missing, Int64}}}},
::Val{:Main}, ::Val{(true, 0, 0, 0, true, 0, 32, 15, 64, 0x0000000000000001, 1, true)}, ::Val{((true,), (true,))})
The problem persists if you create a view dropping missings, since the vector is still Union{Missing,T} and is not allowed.
Many thanks!!! Great package!!!
Yes, this is fixable. If someone wants to make a PR, I could explain the approach and answer any questions.