Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ListOfLoc, BoundedLatt iterable #363

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bloqade/ir/location/bravais.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def enumerate(self) -> Generator[LocationInfo, None, None]:
position = tuple(self.lattice_spacing * pos)
yield LocationInfo(position, True)

def __iter__(self):
for index in itertools.product(*[range(n) for n in self.shape]):
for pos in self.coordinates(index):
position = tuple(self.lattice_spacing * pos)
yield LocationInfo(position, True)

def scale(self, factor: float | Scalar) -> "BoundedBravais":
"""Scale the current location with a factor.

Expand Down
3 changes: 3 additions & 0 deletions src/bloqade/ir/location/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def n_dims(self):
def enumerate(self):
return iter(self.location_list)

def __iter__(self):
return iter(self.location_list)


start = ListOfLocations()
"""
Expand Down
Loading