Skip to content

Preserve element identity in map over sparse transposes and adjoints - #977

Merged
ViralBShah merged 3 commits into
mainfrom
codex/map-sparse-wrapper-elements
Sep 29, 2026
Merged

ViralBShah merged 3 commits into
mainfrom
codex/map-sparse-wrapper-elements

Conversation

@ViralBShah

@ViralBShah ViralBShah commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Fix a regression introduced by #892: map over a sparse transpose or adjoint copied every stored element before calling the mapping function. This broke aliases for mutable elements and threw MethodError: copy(::T) for elements that support transposition but not copying.

Before (main)

julia> block = [1 2; 3 4]; A = SparseMatrixCSC(1, 1, [1, 2], [1], [block]);

julia> only(map(B -> parent(B) === block, transpose(A)))
false

After

julia> only(map(B -> parent(B) === block, transpose(A)))
true

Use ftranspose with the wrapper's transpose or adjoint operation to materialize the sparse structure while preserving references to its elements, then apply the existing mapping kernel. This retains stored zeros and the sparse traversal introduced in #892. Regression coverage uses the shared CountedReads helper to check element identity and the absence of reads to copy block contents, with real and complex matrix blocks for both wrappers.

Also update the trim app's Boolean-mask check for #892's stored-zero behavior: Ai .> 2 keeps all four stored entries, while count still returns three.

Written by Codex.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.83%. Comparing base (fb3e9d5) to head (818b1d3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #977   +/-   ##
=======================================
  Coverage   94.83%   94.83%           
=======================================
  Files          16       16           
  Lines        9248     9248           
=======================================
  Hits         8770     8770           
  Misses        478      478           

☔ 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 c4c99c4 into main Sep 29, 2026
11 checks passed
@ViralBShah
ViralBShah deleted the codex/map-sparse-wrapper-elements branch September 29, 2026 13:00
ViralBShah added a commit that referenced this pull request Oct 9, 2026
…ember (#1017)

Documentation only, drawn from the pull requests merged since early
September and their review comments.

- **PR text.** The rule against reporting routine checks is its own
bullet and names the forms that still got through: test modes passing,
the ambiguity check, the Julia build, pass counts. Titles fit one line
of `git log --oneline`.
- **Added.** Julia's CI flags, `--depwarn=error` and the trim test
(#971, #972); dense results where every entry would be stored (#1004,
#1005, #1007); opaque elements (#982, #977, #1006); fixed test inputs
and `mismatch` (#991, #998).
- **Removed.** Rules that Aqua, `.gitignore` or #990 made unnecessary,
and test detail that `test/AGENTS.md` already holds.
- **`src/solvers/`.** Caller-owned solve workspaces (#914), copying an
aliased right-hand side (#942), validating before a refactorization
(#899, #901). Corrects the lock field names and the index-type testing
rule.
- **`test/`.** Fixed inputs and top-level helper loading (#971); drops
the notes on worker groups, which `runtests.jl` no longer has.
- **`gen/`.** Header order, and running `make` before a change (#1003).

Written by Claude Code (Claude Opus 5.5).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Viral B. Shah <ViralBShah@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant