Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should there be a MissingVector like SparseVector Type? #140

Closed
Tokazama opened this issue Dec 1, 2021 · 5 comments
Closed

Should there be a MissingVector like SparseVector Type? #140

Tokazama opened this issue Dec 1, 2021 · 5 comments

Comments

@Tokazama
Copy link

Tokazama commented Dec 1, 2021

Sometimes I want to have something that is essentially SparseVector but instead of returning zeros it would return missing. Would this be a welcome addition here?

@quinnj
Copy link
Member

quinnj commented Dec 2, 2021

We have this already over at SentinelVectors.jl: https://github.com/JuliaData/SentinelArrays.jl/blob/main/src/missingvector.jl. We could move it here if people would prefer.

@Tokazama
Copy link
Author

Tokazama commented Dec 2, 2021

Sorry, I should be more specific. I mean something that is sparsely populated. SentinalArray still has to allocate memory for values that are NaN in the data field right?

julia> x = SentinelVector{Float64}(undef, 1000);

julia> x[[1, 2, 4]] = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> y = sparsevec(zeros(1000));

julia> y[[1, 2, 4]] = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> Base.summarysize(x)
8056

julia> Base.summarysize(y)
152

@nalimilan
Copy link
Member

I imagine that could be useful, but I'd rather put this in a dedicated package, and keep only simple convenience functions in Missings.jl. It's a standard convention to have packages called XXXArrays.jl defining the XXXArray type.

@quinnj
Copy link
Member

quinnj commented Dec 7, 2021

@Tokazama, sorry, I linked specifically to the "missingvector.jl" file in the SentinelArrays.jl package, which actually is the home to 3 different array types: SentinelArray, MissingVector, and ChainedVector. The MissingVector type is the one I was referring to, which is an efficient representation of an array of missing values, and also supports all the expected mutable operations.

@nalimilan
Copy link
Member

Let's close this then as this should probably not live in Missings.jl anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants