Exemple #1
0
def test_qubit_not_mutated():
    qubit = cirq.GridQubit(0, 0)

    above(qubit)
    assert qubit == cirq.GridQubit(0, 0)

    below(qubit)
    assert qubit == cirq.GridQubit(0, 0)

    right_of(qubit)
    assert qubit == cirq.GridQubit(0, 0)

    left_of(qubit)
    assert qubit == cirq.GridQubit(0, 0)
Exemple #2
0
        def assemble_edges() -> Set[EDGE]:
            """Creates list of edges for initial state.

            Returns:
              List of all possible edges.
            """
            nodes_set = set(self._c)
            edges = set()
            for n in self._c:
                if above(n) in nodes_set:
                    edges.add(self._normalize_edge((n, above(n))))
                if right_of(n) in nodes_set:
                    edges.add(self._normalize_edge((n, right_of(n))))
            return edges
Exemple #3
0
def test_neighbours():
    qubit = cirq.GridQubit(0, 0)
    assert above(qubit) == cirq.GridQubit(0, -1)
    assert below(qubit) == cirq.GridQubit(0, 1)
    assert right_of(qubit) == cirq.GridQubit(1, 0)
    assert left_of(qubit) == cirq.GridQubit(-1, 0)