diff --git a/pytket/phir/sharding/shard.py b/pytket/phir/sharding/shard.py index 00af2ad..41b41ee 100644 --- a/pytket/phir/sharding/shard.py +++ b/pytket/phir/sharding/shard.py @@ -35,21 +35,6 @@ class Shard: # A set of the identifiers of other shards this particular shard depends upon depends_upon: set[int] - # def __post_init__(self) -> None: - # self.qubits_used = set(self.primary_command.qubits) - # self.bits_written = set(self.primary_command.bits) - # self.bits_read = set() - - # all_sub_commands: list[Command] = [] - # for sub_commands in self.sub_commands.values(): - # all_sub_commands.extend(sub_commands) - - # for sub_command in all_sub_commands: - # self.bits_written.update(sub_command.bits) - # self.bits_read.update( - # set(filter(lambda x: isinstance(x, Bit), sub_command.args)), # type: ignore [misc,arg-type] # noqa: E501 - # ) - def pretty_print(self) -> str: output = io.StringIO() output.write(f"Shard {self.ID}:") diff --git a/tests/test_shard.py b/tests/test_shard.py deleted file mode 100644 index e2f03e7..0000000 --- a/tests/test_shard.py +++ /dev/null @@ -1,44 +0,0 @@ -EMPTY_INT_SET: set[int] = set() - - -class TestShard: - pass - # def test_shard_ctor(self) -> None: - # circ = Circuit(4) # qubits are numbered 0-3 - # circ.X(0) # first apply an X gate to qubit 0 - # circ.CX(1, 3) # and apply a CX gate with control qubit 1 and target qubit 3 - # circ.Z(3) # then apply a Z gate to qubit 3 - # commands = circ.get_commands() - - # shard = Shard( - # commands[1], - # {commands[0].qubits[0]: [commands[0]]}, - # EMPTY_INT_SET, - # ) - - # assert shard.primary_command == commands[1] - # assert shard.depends_upon == EMPTY_INT_SET - # sub_command_key, sub_command_value = next(iter(shard.sub_commands.items())) - # assert sub_command_key == commands[0].qubits[0] - # assert sub_command_value[0] == commands[0] - - # def test_shard_ctor_conditional(self) -> None: - # circuit = Circuit(4, 4) - # circuit.H(0) - # circuit.Measure(0, 0) - # circuit.X(1, condition_bits=[0], condition_value=1) # type: ignore [misc] - # circuit.Measure(1, 1) # The command we'll build the shard from - # commands = circuit.get_commands() - - # shard = Shard( - # commands[3], - # { - # circuit.qubits[0]: [commands[2]], - # }, - # EMPTY_INT_SET, - # ) - - # assert len(shard.sub_commands.items()) - # assert shard.qubits_used == {circuit.qubits[1]} - # assert shard.bits_read == {circuit.bits[0]} - # assert shard.bits_written == {circuit.bits[1]} diff --git a/tests/test_sharder.py b/tests/test_sharder.py index 34ad51d..aa1d962 100644 --- a/tests/test_sharder.py +++ b/tests/test_sharder.py @@ -13,7 +13,6 @@ def test_should_op_create_shard(self) -> None: Op.create(OpType.Reset), # type: ignore # noqa: PGH003 Op.create(OpType.CX), # type: ignore # noqa: PGH003 Op.create(OpType.Barrier), # type: ignore # noqa: PGH003 - # Op.create(OpType.SetBits, [3, 1]), ] expected_false: list[Op] = [ Op.create(OpType.U1, 0.32), # type: ignore # noqa: PGH003 @@ -113,7 +112,7 @@ def test_simple_conditional(self) -> None: assert len(shards[2].sub_commands.keys()) == 0 assert shards[2].qubits_used == set() assert shards[2].bits_written == {circuit.bits[1]} - # assert shards[2].bits_read == {circuit.bits[0]} + assert shards[2].bits_read == {circuit.bits[0], circuit.bits[1]} assert shards[2].depends_upon == {shards[0].ID} # shard 3: [if (c==1) h q;] measure q->c;