Skip to content

Commit

Permalink
Quick approach change (#29)
Browse files Browse the repository at this point in the history
* Quick approach change

* list comprehension + difference update

---------

Co-authored-by: Neal Erickson <[email protected]>
  • Loading branch information
neal-erickson and nealerickson-qtm authored Nov 9, 2023
1 parent ac1789b commit 177d1bb
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pytket/phir/sharding/shards2ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ def parse_shards_naive(

while len(scheduled) < num_shards:
layer: list[list[int]] = []
to_schedule: list[Shard] = []
# Iterate the shards, looking for shards whose dependencies have been
# satisfied, or initially, shards with no dependencies
for shard in shards:
if shard.ID not in scheduled:
deps = shard.depends_upon
# dependencies of the shard that have already been scheduled
scheduled_deps = deps.intersection(scheduled)
if scheduled_deps == deps:
to_schedule.append(shard)
to_schedule = [s for s in shards if s.depends_upon.issubset(scheduled)]
shards_in_layer.append(to_schedule)
shards.difference_update(to_schedule)

for shard in to_schedule:
op: list[int] = []
Expand Down

0 comments on commit 177d1bb

Please sign in to comment.