Skip to content

Disambiguate Diagonal{<:LayoutVector} * OffDiagonal - #295

Merged
dlfivefifty merged 2 commits into
masterfrom
diagonal-offdiagonal-mul
Nov 13, 2026
Merged

dlfivefifty merged 2 commits into
masterfrom
diagonal-offdiagonal-mul

Conversation

@dlfivefifty

Copy link
Copy Markdown
Member

Companion to JuliaArrays/FillArrays.jl#465, which makes Diagonal * OffDiagonal and OffDiagonal * Diagonal return an OffDiagonal. Those methods are ambiguous with

*(A::Diagonal{<:Any,<:LayoutVector}, B::AbstractMatrix)
*(A::AbstractMatrix, B::Diagonal{<:Any,<:LayoutVector})

so e.g. Diagonal(BroadcastVector(exp, 1:5)) * OffDiagonal(Ones(4), 1) would become a MethodError. This adds the disambiguations

*(A::Diagonal{<:Number,<:LayoutVector}, B::OffDiagonal)
*(A::OffDiagonal, B::Diagonal{<:Number,<:LayoutVector})

which call the FillArrays implementation when it exists (so return an OffDiagonal, and lazy/infinite bands stay lazy, e.g. Diagonal(BroadcastVector(exp, 1:∞)) * OffDiagonal(Ones(∞), 1, (oneto(∞), oneto(∞))) is an OffDiagonal with a BroadcastArray band), and otherwise fall back to mul as currently. So this works with both the released FillArrays and FillArrays#465, and the @static check can be removed once the FillArrays compat is bumped past that release.

Tested against released FillArrays 1.18.2 (mul fallback) and against the FillArrays#465 branch (returns OffDiagonal); both pass the full test suite including Aqua. Version bumped to 1.16.1.

🤖 Generated with Claude Code

…Diagonal with FillArrays#465

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.74%. Comparing base (4a778aa) to head (d0cb9d8).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/ArrayLayouts.jl 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
+ Coverage   90.66%   90.74%   +0.07%     
==========================================
  Files          12       12              
  Lines        2068     2106      +38     
==========================================
+ Hits         1875     1911      +36     
- Misses        193      195       +2     

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

@dlfivefifty
dlfivefifty merged commit adcd970 into master Nov 13, 2026
5 checks passed
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