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

Fix bug in converting Zeros matrix to Diagonal #389

Merged
merged 4 commits into from
Aug 29, 2024
Merged

Conversation

dlfivefifty
Copy link
Member

@dlfivefifty dlfivefifty commented Aug 28, 2024

Fixes this bug on master:

julia> convert(Diagonal{Int,Vector{Int}}, Zeros{Int}(5,5))
ERROR: MethodError: no method matching Vector{Int64}(::Zeros{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})

Closest candidates are:
  Array{T, N}(::FillArrays.AbstractZeros{V, N}) where {T, V, N}
   @ FillArrays ~/.julia/packages/FillArrays/eOEVm/src/FillArrays.jl:532
  Array{T, N}(::FillArrays.AbstractFill{V, N}) where {T, V, N}
   @ FillArrays ~/.julia/packages/FillArrays/eOEVm/src/FillArrays.jl:526
  Array{T, N}(::AbstractArray{S, N}) where {T, N, S}
   @ Base array.jl:673
  ...

Stacktrace:
 [1] convert(::Type{Vector{Int64}}, a::Zeros{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ Base ./array.jl:665
 [2] Diagonal{Int64, Vector{Int64}}(diag::Zeros{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ LinearAlgebra ~/Projects/julia-1.10/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/diagonal.jl:10
 [3] convert(::Type{Diagonal{Int64, Vector{Int64}}}, A::Zeros{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ FillArrays ~/.julia/packages/FillArrays/eOEVm/src/FillArrays.jl:540
 [4] top-level scope
   @ REPL[3]:1

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.91%. Comparing base (90ef3ce) to head (80b50c4).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #389   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files           8        8           
  Lines        1141     1141           
=======================================
  Hits         1140     1140           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jishnub
Copy link
Member

jishnub commented Aug 29, 2024

Just a side note: convert(Diagonal{Int,Vector{Int}}, Zeros{Int}(5,5)) already works on julia v1.11+

@dlfivefifty
Copy link
Member Author

Does that mean we should only add the special case for VERSION < v"1.11-"?

@jishnub
Copy link
Member

jishnub commented Aug 29, 2024

Yes, this convert method would only be necessary on versions < v"1.11-". This conversion has now been added to LinearAlgebra. We may limit the method to older versions.

@dlfivefifty dlfivefifty merged commit 550d534 into master Aug 29, 2024
25 checks passed
@dlfivefifty dlfivefifty deleted the dl/diagconvertbug branch August 29, 2024 19:21
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.

2 participants