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

Test Any case, where fill! syntax required #100

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

nickrobinson251
Copy link
Contributor

@nickrobinson251 nickrobinson251 commented Aug 28, 2019

I wondered why we use fill! in missings

missings(::Type{T}, dims::Dims) where {T} = fill!(Array{Union{T, Missing}}(undef, dims), missing)

and didn't just define it as Array{Union{T, Missing}}(undef, dims)

Turns out T = Any is the only case that definition wouldn't work for (AFAIK).
So this PR adds tests for that case :)

julia> Array{Union{Int, Missing}}(undef, (2, 3))
2×3 Array{Union{Missing, Int64},2}:
 missing  missing  missing
 missing  missing  missing

julia> struct F end

julia> Array{Union{F, Missing}}(undef, (2, 3))
2×3 Array{Union{Missing, F},2}:
 missing  missing  missing
 missing  missing  missing

julia> Array{Union{Any, Missing}}(undef, (2, 3))
2×3 Array{Any,2}:
 #undef  #undef  #undef
 #undef  #undef  #undef

@codecov-io
Copy link

codecov-io commented Aug 28, 2019

Codecov Report

Merging #100 into master will increase coverage by 3.53%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #100      +/-   ##
========================================
+ Coverage   88.46%    92%   +3.53%     
========================================
  Files           1      1              
  Lines          52     50       -2     
========================================
  Hits           46     46              
+ Misses          6      4       -2
Impacted Files Coverage Δ
src/Missings.jl 92% <0%> (+3.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ac53e9...3315c7a. Read the comment docs.

@rofinn rofinn merged commit d4cf5f9 into JuliaData:master Aug 30, 2019
@nickrobinson251 nickrobinson251 deleted the npr/a-test branch August 30, 2019 18:07
@nalimilan
Copy link
Member

Actually fill! is also needed for some Union types, where Missing isn't guaranteed to be the first type.

@nickrobinson251
Copy link
Contributor Author

nickrobinson251 commented Sep 3, 2019

Actually fill! is also needed for some Union types, where Missing isn't guaranteed to be the first type.

Good to know! Thanks for clarifying :) At least we now have a test for one case where fill! is required

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

Successfully merging this pull request may close these issues.

5 participants