Bit matrix of non-NaNs

You need one more dot…

julia> @. !isnan(YY)  # macro adds dots everywhere
10×3 BitMatrix:
 1  1  1
 0  1  1
...

julia> .!isnan.(YY)  # infix operator takes . before, like .*
10×3 BitMatrix:
 1  1  1
...

julia> (!isnan).(YY)  # uses !(::Function)
10×3 BitMatrix:
 1  1  1
...

julia> typeof(!isnan)
ComposedFunction{typeof(!), typeof(isnan)}

julia> Meta.@lower !isnan.(YY)  # failed case, broadcasts then applies ! to array
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope`
1 ─ %1 = !
│   %2 = Base.broadcasted(isnan, YY)
│   %3 = Base.materialize(%2)
│   %4 = (%1)(%3)
└──      return %4
))))

julia> Meta.@lower .!isnan.(YY)  # one fused broadcast
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope`
1 ─ %1 = !
│   %2 = Base.broadcasted(isnan, YY)
│   %3 = Base.broadcasted(%1, %2)
│   %4 = Base.materialize(%3)
└──      return %4
))))
4 Likes