Skip to content

Add findnz for adjoint/transpose of sparse matrices and vectors - #765

Merged
ViralBShah merged 1 commit into
mainfrom
vs/findnz-adjoint
Sep 7, 2026
Merged

Add findnz for adjoint/transpose of sparse matrices and vectors#765
ViralBShah merged 1 commit into
mainfrom
vs/findnz-adjoint

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

findnz(A') threw a MethodError for a sparse matrix A.

This PR adds:

  • findnz(::AdjOrTrans{<:Any,<:AbstractSparseMatrixCSC}), implemented via the linear-time materialized transpose so that (I, J, V) come out in column-major order of the wrapper, matching findnz(SparseMatrixCSC(A')).
  • findnz(::AdjOrTrans{<:Any,<:SparseVectorUnion}), returning (I, J, V) for the 1×n wrapper with values adjointed/transposed as appropriate.
  • A docstring note and tests covering real/complex, adjoint/transpose, empty inputs, and consistency with the materialized result.

Test.detect_ambiguities(SparseArrays) remains empty.

Fixes #632

🤖 Generated with Claude Code

https://claude.ai/code/session_01XzN6CtuVBJWDVc88ShNYso

`findnz(A')` threw a `MethodError` for sparse `A`. Add methods for
`Adjoint`/`Transpose` wrappers of `AbstractSparseMatrixCSC` (via the
linear-time materialized transpose, so indices come out in column-major
order of the wrapper) and of sparse vectors (returning `(I, J, V)` with
the values adjointed/transposed as appropriate).

Fixes #632

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XzN6CtuVBJWDVc88ShNYso
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.15%. Comparing base (4ba7b1c) to head (306ecca).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
+ Coverage   83.99%   84.15%   +0.16%     
==========================================
  Files          13       13              
  Lines        9366     9386      +20     
==========================================
+ Hits         7867     7899      +32     
+ Misses       1499     1487      -12     

☔ 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.

@ViralBShah
ViralBShah merged commit c9deb4a into main Sep 7, 2026
11 checks passed
@ViralBShah
ViralBShah deleted the vs/findnz-adjoint branch September 7, 2026 23:56
Sign up for free to 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.

findnz fail for adjoint sparse matrix

1 participant