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

Specialize haszero for Union{Missing,<:Number} #56169

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Oct 15, 2024

Since zero(::Union{Missing,T}) calls zero(T) internally, we may use the same logic for LinearAlgebra.haszero. This helps with certain structured matrix operations:

julia> M = Matrix{Union{Int,Missing}}(missing,2,2)
2×2 Matrix{Union{Missing, Int64}}:
 missing  missing
 missing  missing

julia> triu(M)
2×2 Matrix{Union{Missing, Int64}}:
  missing  missing
 0         missing

whereas previously, this would have been

julia> triu(M)
2×2 Matrix{Union{Missing, Int64}}:
 missing  missing
 missing  missing

@jishnub jishnub added the linear algebra Linear algebra label Oct 15, 2024
@ararslan ararslan added the missing data Base.missing and related functionality label Oct 16, 2024
@jishnub jishnub merged commit 82e0e28 into master Oct 21, 2024
5 of 7 checks passed
@jishnub jishnub deleted the jishnub/_zero_missing branch October 21, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra missing data Base.missing and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants