Skip to content

Updating api for grid.get_view to be more flexible#29

Merged
weinbe58 merged 1 commit intomainfrom
phil/update-get-view-iterface
Oct 3, 2025
Merged

Updating api for grid.get_view to be more flexible#29
weinbe58 merged 1 commit intomainfrom
phil/update-get-view-iterface

Conversation

@weinbe58
Copy link
Member

@weinbe58 weinbe58 commented Oct 3, 2025

This PR expands the types allowed by the get_view method to be a bit more flexible. The underlying implementation doesn't care so much about the exact data types. This PR makes this flexibility clearer.

Copilot AI review requested due to automatic review settings October 3, 2025 15:20
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 updates the get_view method in the Grid class to accept more flexible input types by adding overloads that support both ilist.IList and generic Sequence[int] for the indices parameters. The implementation is updated to handle both types internally by extracting data from ilist.IList objects when needed.

  • Added multiple overloads for get_view to support different combinations of ilist.IList and Sequence[int] parameter types
  • Updated the implementation to convert ilist.IList objects to their underlying data before creating new IList objects
  • Modified tests to use is_subseteq instead of is_equal for type checking

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/bloqade/geometry/dialects/grid/types.py Added overloaded method signatures and updated implementation to handle flexible input types
test/grid/test_typeinfer.py Changed type assertions from is_equal to is_subseteq
Comments suppressed due to low confidence (1)

src/bloqade/geometry/dialects/grid/types.py:463

  • The SubGrid.get_view method assumes x_indices and y_indices are iterable with integer indexing, but it doesn't handle the case where they might be ilist.IList objects. This could cause issues when accessing elements via x_indices[x_index]. The method should extract the underlying data from ilist.IList objects similar to the parent Grid.get_view implementation.
    def get_view(self, x_indices, y_indices):
        return self.parent.get_view(
            x_indices=ilist.IList([self.x_indices[x_index] for x_index in x_indices]),
            y_indices=ilist.IList([self.y_indices[y_index] for y_index in y_indices]),
        )

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-10-03 15:22 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
406 378 93% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/bloqade/geometry/dialects/grid/types.py 86% 🟢
TOTAL 86% 🟢

updated for commit: 9157f7b by action🐍

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@weinbe58 weinbe58 merged commit 961a53b into main Oct 3, 2025
13 checks passed
@weinbe58 weinbe58 deleted the phil/update-get-view-iterface branch October 3, 2025 15:21
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