diff --git a/src/shift.jl b/src/shift.jl index d69712e..10b90a5 100644 --- a/src/shift.jl +++ b/src/shift.jl @@ -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 diff --git a/test/rank.jl b/test/rank.jl index 15abe87..d9e582f 100644 --- a/test/rank.jl +++ b/test/rank.jl @@ -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