From ee34da2f25e2d0a2b9f20b48a911c7982a18a699 Mon Sep 17 00:00:00 2001 From: simone bordoni Date: Wed, 14 Feb 2024 14:58:39 +0400 Subject: [PATCH] avoid raise_error in block decomposition --- src/qibo/transpiler/blocks.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/qibo/transpiler/blocks.py b/src/qibo/transpiler/blocks.py index 5b881d9e06..6e2b1122a2 100644 --- a/src/qibo/transpiler/blocks.py +++ b/src/qibo/transpiler/blocks.py @@ -65,8 +65,8 @@ def fuse(self, block, name: Optional[str] = None): (:class:`qibo.transpiler.blocks.Block`): fusion of the two input blocks. """ if not self.qubits == block.qubits: - raise BlockingError( - "In order to fuse two blocks their qubits must coincide." + raise_error( + BlockingError, "In order to fuse two blocks their qubits must coincide." ) return Block(qubits=self.qubits, gates=self.gates + block.gates, name=name) @@ -200,12 +200,11 @@ def block_decomposition(circuit: Circuit, fuse: bool = True): remove_list = [first_block] if len(initial_blocks[1:]) > 0: for second_block in initial_blocks[1:]: - try: + if second_block.qubits == first_block.qubits: first_block = first_block.fuse(second_block) remove_list.append(second_block) - except BlockingError: - if not first_block.commute(second_block): - break + elif not first_block.commute(second_block): + break blocks.append(first_block) _remove_gates(initial_blocks, remove_list)