def test_single_wires_blocking(self): """Test single wire gates blocking each other""" ops = [qml.PauliX(0), qml.PauliX(0), qml.PauliX(0)] layers = drawable_layers(ops) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}]
def test_single_wires_no_blocking(self): """Test simple case where nothing blocks each other""" ops = [qml.PauliX(0), qml.PauliX(1), qml.PauliX(2)] layers = drawable_layers(ops) assert layers == [set(ops)]
def test_all_wires_measurement(self, measurement): """Test measurements that act on all wires also block on all available wires.""" ops = [qml.PauliX(0), measurement, qml.PauliY(1)] layers = drawable_layers(ops) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}]
def test_multiwire_blocking(self, multiwire_gate): """Test multi-wire gate blocks on unused wire""" wire_map = {0: 0, 1: 1, 2: 2, 3: 3} ops = [qml.PauliZ(1), multiwire_gate, qml.PauliX(1)] layers = drawable_layers(ops, wire_map=wire_map) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}]
def test_barrier_only_visual(self): """Test the barrier is always drawn""" ops = [ qml.PauliX(0), qml.Barrier(wires=0), qml.Barrier(only_visual=True, wires=0), qml.PauliX(0), ] layers = drawable_layers(ops) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}, {ops[3]}]
def test_barrier_block(self): """Test the barrier blocking operators""" ops = [qml.PauliX(0), qml.Barrier(wires=[0, 1]), qml.PauliX(1)] layers = drawable_layers(ops) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}]