I think this is more about reductions with dims
keyword arg not dropping the reduced dimension. There’s a somewhat long discussion about it in the relevant github issue: https://github.com/JuliaLang/julia/issues/16606.
In this specific case, I think rewriting it as @mcabbott has suggested is the nicest solution. But more generally, you can just drop the extra dimension yourself:
idx = .!any(isnan.(X), dims=2)[:,1]
or
idx = dropdims(.!any(isnan.(X), dims=2), dims=2)
a bit ugly too, but clearer than reshape
, I think.