Exemplo n.º 1
0
def test_permutation_gate_maps(maps, permutation):
    qs = cirq.LineQubit.range(len(permutation))
    permutationOp = cirq.QubitPermutationGate(permutation).on(*qs)
    circuit = cirq.Circuit(permutationOp)
    cirq.testing.assert_equivalent_computational_basis_map(maps, circuit)
    circuit = cirq.Circuit(cirq.I.on_each(*qs), cirq.decompose(permutationOp))
    cirq.testing.assert_equivalent_computational_basis_map(maps, circuit)
Exemplo n.º 2
0
def test_permutation_gate_json_dict():
    assert cirq.QubitPermutationGate([0, 1, 2])._json_dict_() == {
        'permutation': (0, 1, 2)
    }
Exemplo n.º 3
0
def test_setters_deprecated():
    gate = cirq.QubitPermutationGate((1, 2, 0))
    assert gate.permutation == (1, 2, 0)
    with cirq.testing.assert_deprecated('mutators', deadline='v0.15'):
        gate.permutation = (2, 1, 0)
        assert gate.permutation == (2, 1, 0)