Skip to content

Collapse all-zero tuple projections after projecting - #725

Merged
devmotion merged 4 commits into
mainfrom
dmw/tuple-projector-collapse
Oct 30, 2026
Merged

devmotion merged 4 commits into
mainfrom
dmw/tuple-projector-collapse

Conversation

@devmotion

Copy link
Copy Markdown
Member

ProjectTo{<:Tangent{<:Tuple}} applied to an AbstractArray checked the unprojected elements dy for all-zero instead of the projected ones dz, so elements that only become zero during projection (e.g. tangents for Bools) didn't collapse to NoTangent():

julia> ProjectTo((true, 1.0))(Any[2.0, ZeroTangent()])
Tangent{Tuple{Bool, Float64}}(NoTangent(), ZeroTangent())   # before
NoTangent()                                                  # after

Both tuple methods now check dz isa Tuple{Vararg{AbstractZero}} instead of all(d -> d isa AbstractZero, ...). This is equivalent for tuples, and the result is inferrable. Tests cover the collapse and inference for tuple and array inputs.

Split out from #724.

🤖 Generated with Claude Code

devmotion and others added 4 commits October 30, 2026 17:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (4e9c8aa) to head (11caa30).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #725      +/-   ##
==========================================
+ Coverage   93.54%   93.63%   +0.09%     
==========================================
  Files          15       15              
  Lines        1022     1022              
==========================================
+ Hits          956      957       +1     
+ Misses         66       65       -1     

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

@devmotion
devmotion merged commit 0ae32d8 into main Oct 30, 2026
27 checks passed
@devmotion
devmotion deleted the dmw/tuple-projector-collapse branch October 30, 2026 17:57
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