예제 #1
0
    def test_show_all_wires_true(self):
        """Test when `show_all_wires` is set to `True` everything in ``wire_order`` is included."""

        ops = [qml.PauliX("a"), qml.PauliY("c")]
        wire_order = ["a", "b", "c", "d"]

        wire_map = convert_wire_order(ops, wire_order, show_all_wires=True)
        assert wire_map == {"a": 0, "b": 1, "c": 2, "d": 3}
예제 #2
0
    def test_show_all_wires_false(self):
        """Test when `show_all_wires` is set to `False` only used wires are in the map."""

        ops = [qml.PauliX("a"), qml.PauliY("c")]
        wire_order = ["a", "b", "c", "d"]

        wire_map = convert_wire_order(ops, wire_order, show_all_wires=False)
        assert wire_map == {"a": 0, "c": 1}
예제 #3
0
    def test_wire_order_ints(self):
        """Tests wire map produced when initial wires are integers."""

        ops = [qml.PauliX(0), qml.PauliX(2), qml.PauliX(1)]
        wire_order = [2, 1, 0]

        wire_map = convert_wire_order(ops, wire_order)
        assert wire_map == {2: 0, 1: 1, 0: 2}
예제 #4
0
    def test_wire_order_str(self):
        """Test wire map produced when initial wires are strings."""

        ops = [qml.CNOT(wires=("a", "b")), qml.PauliX("c")]
        wire_order = ("c", "b", "a")

        wire_map = convert_wire_order(ops, wire_order)
        assert wire_map == {"c": 0, "b": 1, "a": 2}
예제 #5
0
    def test_no_wire_order(self):
        """Test that a wire map is produced if no wire order is passed."""

        ops = [qml.PauliX(0), qml.PauliX(2), qml.PauliX(1)]

        wire_map = convert_wire_order(ops)

        assert wire_map == {0: 0, 2: 1, 1: 2}