Julia: No isnull for arrays?

Created on 29 Apr 2016  Â·  7Comments  Â·  Source: JuliaLang/julia

Base doesn't have any way of checking which positions in an array have valid values.

``` .julia
a = Nullable{Float64}[]
for i in 1:10
push!(a, Nullable{Float64}())
end
a[1] = 2.0
isnull(a)

while the following works

``` .julia
map(x -> isnull(x), a)

Most helpful comment

map(isnull, a)

All 7 comments

What do you envision isnull(a) meaning?

Returning a boolean array with the values that are null. Something
similar to how isna already operates.

On Thu, Apr 28, 2016, at 17:56, John Myles White wrote:

What do you envision isnull(a) meaning?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub[1]

Links:

  1. https://github.com/JuliaLang/julia/issues/16112#issuecomment-215604347

So it would be vectorized. I think that's not the best path forward for two reasons:

  • We want to remove vectorized functions, not add more of them.
  • It's actually very reasonable to imagine that isnull(a) should return a Boolean.

map(isnull, a)

Thanks everyone for weighing in. I guess with #13412 merged, using an anonymous function will be plenty fast.

@tlnagy As @andreasnoack said, you don't need an anonymous function at all, so it's already fast in 0.4. Also, with the syntax proposed at https://github.com/JuliaLang/julia/issues/8450, you might be able to write it as isnull.(a) at some point.

@nalimilan Good catch. I thought that used an anonymous function internally, but now I realize that doesn't make too much sense. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wilburtownsend picture wilburtownsend  Â·  3Comments

musm picture musm  Â·  3Comments

arshpreetsingh picture arshpreetsingh  Â·  3Comments

TotalVerb picture TotalVerb  Â·  3Comments

m-j-w picture m-j-w  Â·  3Comments