Use FillArrays.simplify_broadcasted for Zeros broadcasts - #506
Draft
jishnub wants to merge 1 commit into
Draft
Conversation
The `Zeros` rules called `FillArrays._broadcasted_zeros`, an internal, and duplicated FillArrays' own list of which operations a `Zeros` absorbs. `FillArrays.simplify_broadcasted(style, op, args...)` replaces both. It returns the simplified array where a rule applies, and otherwise a `Broadcasted` carrying the style we passed in, so anything it cannot simplify comes back to us unchanged. The methods no longer enumerate operations, and they now key on `AbstractZeros` rather than the concrete `Zeros`. The `Ones` rules are left alone: they preserve bandedness via `_copy_oftype`, which is our semantics rather than FillArrays'. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jishnub
marked this pull request as draft
August 10, 2026 18:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on JuliaArrays/FillArrays.jl#444 (FillArrays 1.19). CI will not resolve until that is merged and released — the compat bound here is raised to
FillArrays = "1.19".Why
The
Zerosrules ingeneric/broadcast.jlcalledFillArrays._broadcasted_zeros, an internal imported at the top ofBandedMatrices.jl, and duplicated FillArrays' own list of which operations aZerosabsorbs (*,/one way;*,\the other). If FillArrays gains or changes a rule, this list silently falls out of step.What changes
FillArrays.simplify_broadcasted(style, op, args...)returns the simplified array where a rule applies, and otherwise aBroadcastedcarrying the style we hand it — so anything it cannot simplify comes straight back forBandedStyleto handle as before.No operations are enumerated, and
_broadcasted_zerosis dropped from the import list.The
Onesrules are deliberately left as they were: they preserve bandedness via_copy_oftype, which is our semantics rather than FillArrays', and routing them throughsimplify_broadcastedwould lose that.One incidental fix: the
Zerosmethods keyed on the concreteZeros, soAbstractZerossubtypes were missed. They now key onAbstractZeros. The third method disambiguates the first two when both arguments are zeros.Test suite passes against FillArrays#444.
🤖 Generated with Claude Code