Skip to content

Fix bandwidths of blocks of banded matrices - #252

Merged
dlfivefifty merged 1 commit into
masterfrom
banded-blockslice-bandwidths
Sep 30, 2026
Merged

dlfivefifty merged 1 commit into
masterfrom
banded-blockslice-bandwidths

Conversation

@dlfivefifty

Copy link
Copy Markdown
Member

bandwidths(view(A, Block(K), Block(J))) returned subblockbandwidths(A) for any A, ignoring the offset of the block from the diagonal. For a banded (not block-banded) parent with blocked axes, this disagrees with bandeddata of the view, so indexing an off-diagonal block threw:

using BandedMatrices, BlockArrays, BlockBandedMatrices
B = BandedMatrices._BandedMatrix(BlockedArray(randn(5,6), (Base.OneTo(5), blockedrange(1:3))), blockedrange(1:2), 2, 2)
B[Block(2,3)] # BoundsError: attempt to access ... at index [-1:2, BlockSlice(Block(3),4:6)]

For lazy infinite banded matrices, such as products in ClassicalOrthogonalPolynomials/DeRhamOrthogonalPolynomials, A[Block(3,2)] failed instead, because subblockbandwidths is computed from the maximum block size of an infinite axis.

Now, when the parent has an AbstractBandedLayout, the bandwidths are the parent's bandwidths shifted by the block's offset from the diagonal, as for unit-range views in BandedMatrices. DiagonalLayout parents keep the previous behaviour, which the existing tests rely on.

🤖 Generated with Claude Code

bandwidths(view(A, Block(K), Block(J))) returned subblockbandwidths(A)
for any parent, ignoring the offset of the block from the diagonal. For a
banded (not block-banded) parent this was inconsistent with bandeddata,
so indexing off-diagonal blocks threw a BoundsError, and for lazy infinite
banded matrices it called subblockbandwidths, which fails on infinite axes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 90.79%. Comparing base (761b49e) to head (c1f8154).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #252      +/-   ##
==========================================
+ Coverage   90.76%   90.79%   +0.03%     
==========================================
  Files          11       11              
  Lines        1169     1173       +4     
==========================================
+ Hits         1061     1065       +4     
  Misses        108      108              

☔ 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 5e1f04b into master Sep 30, 2026
19 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