Skip to content

Fix ProjectTo for symmetric sparse matrices. - #707

Open
samuelsonric wants to merge 1 commit into
JuliaDiff:mainfrom
samuelsonric:main
Open

Fix ProjectTo for symmetric sparse matrices.#707
samuelsonric wants to merge 1 commit into
JuliaDiff:mainfrom
samuelsonric:main

Conversation

@samuelsonric

@samuelsonricsamuelsonric commented Mar 31, 2026

Copy link
Copy Markdown

There PR fixes a bug in the ProjectTo function for Symmetric (and Hermitian)-wrapped sparse matrices.

julia> using ChainRulesCore, LinearAlgebra, SparseArrays
julia> A =Hermitian(triu(sprand(100, 100, .1)));
julia> ProjectTo(A)(A) == A
false

The comparison now correctly returns true.

@samuelsonricsamuelsonric changed the title ProjectTo for symmetric sparse matrices.Fix ProjectTo for symmetric sparse matrices.Mar 31, 2026
@codecov

codecovBot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.50575% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.00%. Comparing base (dad0d24) to head (7730590).
⚠️ Report is 3 commits behind head on main.

Files with missing linesPatch %Lines
ext/ChainRulesCoreSparseArraysExt.jl88.50%10 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #707 +/- ##
==========================================
- Coverage 93.40% 93.00% -0.40% 
==========================================
Files 15 15 Lines 1000 1087 +87 ==========================================
+ Hits 934 1011 +77 - Misses 66 76 +10 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

using ChainRulesCore
using ChainRulesCore: project_type, _projection_mismatch
using SparseArrays: SparseVector, SparseMatrixCSC, nzrange, rowvals
using LinearAlgebra: Hermitian, Symmetric, tril, triu

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinearAlgebra is not available in the SparseArrays extension. Only ChainRulesCore and SparseArrays are.

Sign up for freeto 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

@samuelsonric@devmotion