Skip to content

Commit

Permalink
Fix rank warning
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 2, 2024
1 parent 8eab7b0 commit bcc1bf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function is_dependent!(r::RankDependence, row)
new_rank = LinearAlgebra.rank(r.matrix[rows, :], r.check)
if new_rank < r.old_rank
@warn(
"After adding rows, the rank dropped from `$old_rank` to `$new_rank`. Correcting the rank to `$old_rank` and continuing."
"After adding rows, the rank dropped from `$(r.old_rank)` to `$new_rank`. Correcting the rank to `$(r.old_rank)` and continuing."
)
new_rank = r.old_rank
end
Expand Down
14 changes: 14 additions & 0 deletions test/rank.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@
ldlt = low_rank_ldlt(M, SVDLDLT(), 1e-10)
@test ldlt.L -normalize(v)
end

struct HardcodedRanks <: RankCheck
r::Vector{Int}
end

MultivariateMoments.rank_from_singular_values(σ, r::HardcodedRanks) = r.r[length(σ)]

@testset "Decreasing rank" begin
r = RankDependence(zeros(4, 4), HardcodedRanks([1, 0, 1, 2]))
@test !is_dependent!(r, 1)
@test is_dependent!(r, 2)
@test is_dependent!(r, 3)
@test is_dependent!(r, 4)
end

0 comments on commit bcc1bf6

Please sign in to comment.