Ejemplo n.º 1
0
def test_TwiddleGate_text_unicode_diagram():
    qubit = LineQubit.range(1)
    circuit = cirq.Circuit(_TwiddleGate(2, 8).on(*qubit))

    assert circuit.to_text_diagram().strip() == """
0: ───ω^2_8───
    """.strip()
Ejemplo n.º 2
0
def test_TwiddleGate_text_diagram():
    qubit = LineQubit.range(1)
    circuit = cirq.Circuit(_TwiddleGate(2, 8).on(*qubit))

    assert circuit.to_text_diagram(use_unicode_characters=False).strip() == """
0: ---w^2_8---
    """.strip()
Ejemplo n.º 3
0
def test_TwiddleGate_transform(k, n, qubit, initial, expected):
    qubits = LineQubit.range(2)
    initial_state = _single_fermionic_modes_state(initial)
    expected_state = _single_fermionic_modes_state(expected)

    circuit = cirq.Circuit(_TwiddleGate(k, n).on(qubits[qubit]))
    state = circuit.final_wavefunction(initial_state,
                                       qubits_that_should_be_present=qubits)

    assert np.allclose(state, expected_state, rtol=0.0)