Skip to content

Conversation

@WanHsuanLin
Copy link
Contributor

  1. Add implementation for subgrid_shift_x and subgrid_shift_y as described in Shift subset of positions defined by a list of indices. #31
  2. Add assertion to check if the shift operation causes column/row order changes
  3. Can take ilist.IList and slice as input for column/row indices
  4. Add test cases.

@weinbe58 weinbe58 requested a review from Copilot October 14, 2025 22:06
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements subgrid shift functionality for Grid objects, allowing selective shifting of columns and rows while preserving grid integrity. The implementation adds methods to shift specific column or row indices by a given amount while automatically adjusting spacing to maintain grid structure.

  • Adds shift_subgrid_x and shift_subgrid_y methods with support for both ilist.IList and slice inputs
  • Implements validation to prevent invalid shifts that would change column/row ordering
  • Includes comprehensive test coverage for various scenarios including edge cases

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/bloqade/geometry/dialects/grid/types.py Core implementation of subgrid shift methods with spacing adjustment logic
src/bloqade/geometry/dialects/grid/stmts.py Statement definitions for the new shift operations
src/bloqade/geometry/dialects/grid/concrete.py Concrete interpreter implementations for subgrid shift statements
src/bloqade/geometry/dialects/grid/_interface.py Public API interface definitions with documentation
src/bloqade/geometry/dialects/grid/init.py Module exports for new shift operations
test/grid/test_types.py Comprehensive test cases covering various input types and edge cases
test/grid/test_concrete.py Integration tests for concrete interpreter functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just make sure to run pre-commit install and pre-commit run --all-files to get the linting CI to pass

@weinbe58
Copy link
Member

closes #33

Comment on lines +404 to +406
assert all(
x >= 0 for x in new_spacing
), "Invalid shift: column order changes after shift."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a user input we should make this an exception instead of an assertion. Generally Assertions are used to enforce internal logic inside a code to catch potential bugs while exceptions are indicating invalid inputs from a user.

@weinbe58 weinbe58 mentioned this pull request Oct 16, 2025
@weinbe58 weinbe58 merged commit ddac3aa into QuEraComputing:main Oct 16, 2025
8 of 10 checks passed
weinbe58 added a commit that referenced this pull request Oct 16, 2025
* add test cases for sub grid shift

* add test in test_concrete

* add implementation for shift_subgrid_x and shift_subgrid_y

* add test for shift_sub_grid_x/y with slice

* add implementation for shift_sub_grid_x/y with slice

* fix format

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* fix format

---------

Co-authored-by: Phillip Weinberg <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants