JuliaArrays / BlockDiagonals.jl

Functionality for working efficiently with block diagonal matrices.
MIT License
51 stars 11 forks source link

Fix _densification_pullback bug #111

Closed mzgubic closed 2 years ago

mzgubic commented 2 years ago

Found in https://github.com/invenia/LinearMixingModels.jl/issues/51

Previously we had

julia> test_rrule(Matrix, D, output_tangent=UpperTriangular(rand(4, 4)))
test_rrule: Matrix on BlockDiagonal{Float64, Matrix{Float64}}: Error During Test at /Users/mzgubic/.julia/environments/v1.7/dev/ChainRulesTestUtils/src/testers.jl:193
  Got exception outside of a @test
  MethodError: no method matching _densification_pullback(::UpperTriangular{Float64, Matrix{Float64}}, ::Type{BlockDiagonal{Float64, Matrix{Float64}}}, ::Vector{Int64}, ::Vector{Int64})
  Closest candidates are:
    _densification_pullback(::ChainRulesCore.AbstractThunk, ::Any, ::Any, ::Any) at ~/JuliaEnvs/LinearMixingModels.jl/dev/BlockDiagonals/src/chainrules.jl:39
    _densification_pullback(::Matrix, ::Any, ::Any, ::Any) at ~/JuliaEnvs/LinearMixingModels.jl/dev/BlockDiagonals/src/chainrules.jl:28

This fixes the bug

codecov[bot] commented 2 years ago

Codecov Report

Merging #111 (e7f8c20) into master (7bac0da) will decrease coverage by 0.18%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage   96.17%   95.98%   -0.19%     
==========================================
  Files           5        5              
  Lines         340      324      -16     
==========================================
- Hits          327      311      -16     
  Misses         13       13              
Impacted Files Coverage Δ
src/chainrules.jl 100.00% <100.00%> (ø)
src/blockdiagonal.jl 86.76% <0.00%> (-0.56%) :arrow_down:
src/linalg.jl 95.34% <0.00%> (-0.21%) :arrow_down:
src/base_maths.jl 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.