Skip to content

Fix BlockLinearOperator._getitem slicing for cross-block indices#130

Open
robrui wants to merge 1 commit intocornellius-gp:mainfrom
robrui:fix-blocklinearoperator-getitem
Open

Fix BlockLinearOperator._getitem slicing for cross-block indices#130
robrui wants to merge 1 commit intocornellius-gp:mainfrom
robrui:fix-blocklinearoperator-getitem

Conversation

@robrui
Copy link
Copy Markdown

@robrui robrui commented May 8, 2026

The modulo check used num_blocks instead of block_size, so slices aligned to individual blocks (e.g. bd[:12, :12] with block_size=12) were incorrectly handled. Cross-block slices (row blocks != col blocks) fell through to block-level indexing instead of the generic path, producing non-square sub-blocks.

Three fixes:

  • Use block_size instead of num_blocks for alignment checks
  • Detect cross-block slices and fall back to the generic super()._getitem()
  • Select blocks from the batch dimension rather than passing block indices as matrix row/col indices

The modulo check used num_blocks instead of block_size, so slices
aligned to individual blocks (e.g. bd[:12, :12] with block_size=12)
were incorrectly handled. Also, cross-block slices (row blocks !=
col blocks) fell through to block-level indexing instead of the
generic path, producing non-square sub-blocks.

Fix uses block_size for alignment checks, detects cross-block slices
and falls back to the generic super()._getitem(), and selects
blocks from the batch dimension rather than passing block indices
as matrix row/col indices.
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