Example #1
0
def test_quil_one_qubit_gate_eq():
    gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    gate2 = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    assert (cirq.approx_eq(gate, gate2, atol=1e-16))
    gate3 = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    gate4 = QuilOneQubitGate(np.array([[1, 0], [0, 2]]))
    assert (not cirq.approx_eq(gate4, gate3, atol=1e-16))
def test_quil_one_qubit_gate_eq():
    with cirq.testing.assert_deprecated(deadline='v1.0', count=4):
        gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
        gate2 = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
        assert cirq.approx_eq(gate, gate2, atol=1e-16)
        gate3 = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
        gate4 = QuilOneQubitGate(np.array([[1, 0], [0, 2]]))
        assert not cirq.approx_eq(gate4, gate3, atol=1e-16)
Example #3
0
def test_quil_one_qubit_gate_output():
    (q0, ) = _make_qubits(1)
    gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    output = cirq.QuilOutput((gate.on(q0), ), (q0, ))
    assert (str(output) == """# Created using Cirq.

DEFGATE USERGATE1:
    1.0+0.0i, 0.0+0.0i
    0.0+0.0i, 1.0+0.0i
USERGATE1 0
""")
def test_quil_one_qubit_gate_output():
    (q0, ) = _make_qubits(1)
    with cirq.testing.assert_deprecated(deadline='v1.0', count=7):
        gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
        output = cirq.QuilOutput((gate.on(q0), ), (q0, ))
        assert (str(output) == """# Created using Cirq.

DEFGATE USERGATE1:
    1.0+0.0i, 0.0+0.0i
    0.0+0.0i, 1.0+0.0i
USERGATE1 0
""")
def test_quil_one_qubit_gate_repr():
    with cirq.testing.assert_deprecated(deadline='v1.0', count=1):
        gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
        assert repr(gate) == (
            """cirq.circuits.quil_output.QuilOneQubitGate(matrix=
[[1 0]
 [0 1]]
)""")
Example #6
0
def test_quil_one_qubit_gate_repr():
    gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    assert repr(gate) == (
        """cirq.circuits.quil_output.QuilOneQubitGate(matrix=
[[1 0]
 [0 1]]
)"""
    )
Example #7
0
def test_parseable_defgate_output():
    pyquil = pytest.importorskip("pyquil")
    q0, q1 = _make_qubits(2)
    operations = [
        QuilOneQubitGate(np.array([[1, 0], [0, 1]])).on(q0),
        QuilTwoQubitGate(
            np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                      [0, 0, 0, 1]])).on(q0, q1)
    ]
    output = cirq.QuilOutput(operations, (q0, q1))
    # Just checks that we can create a pyQuil Program without crashing.
    pyquil.Program(str(output))
Example #8
0
def test_two_quil_one_qubit_gate_output():
    q0, = _make_qubits(1)
    gate = QuilOneQubitGate(np.array([[1, 0], [0, 1]]))
    gate1 = QuilOneQubitGate(np.array([[2, 0], [0, 3]]))
    output = cirq.QuilOutput((
        gate.on(q0),
        gate1.on(q0),
    ), (q0,))
    assert str(output) == """# Created using Cirq.