JuliaSmoothOptimizers / PartitionedVectors.jl

Other
8 stars 1 forks source link

Fix partitioned linear-operator for Vector (test only) #29

Closed paraynaud closed 1 year ago

paraynaud commented 1 year ago

@dpo, I had a failed test on some of my last PRs. I used to re-run the failed test, but i wanted to fix it before v0.2.0.

The error came from the partitioned linear-operator based on Vector (and not on PartitionedVector). This operator is made to check that solutions from CG for PartitionedVectors and Vectors are the same. Generally it works fine, but sometimes, for an unknown reason, the following code:

grad = rand(n)
pm_v = LinearOperator_for_Vector(epm)
solver_vector = Krylov.CgSolver(pm_v, grad)

Krylov.solve!(solver_vector, pm_v, -grad)
x_vector = solution(solver_vector)

will return x_vector with every component as NaN.

I made additional tests and

Matrix(pm_v)

return some NaN while Matrix(epm) doesn't. More generally pm_v * rand(n) may return some NaN (i don't know why). It is really strange because if you run pm_v * rand(n) twice, you may not have the same result. One may have Nans while the other doesn't.

To avoid failure of continuous integration tests, this PR check that x_vector (result of CG for Vectors) doesn't have NaN before comparing it with the result of CG for PartitionedVectors.

codecov[bot] commented 1 year ago

Codecov Report

Base: 99.07% // Head: 99.07% // No change to project coverage :thumbsup:

Coverage data is based on head (11e3338) compared to base (303275a). Patch has no changes to coverable lines.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #29 +/- ## ======================================= Coverage 99.07% 99.07% ======================================= Files 6 6 Lines 217 217 ======================================= Hits 215 215 Misses 2 2 ``` Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.