Exemplo n.º 1
0
def test_circuit_on_qubits_errors():
    smallc = Circuit(2)
    smallc.add((gates.H(i) for i in range(2)))
    with pytest.raises(ValueError):
        next(smallc.on_qubits(0, 1, 2))

    smallc = Circuit(2)
    smallc.add(gates.Flatten(4 * [0.5]))
    with pytest.raises(NotImplementedError):
        next(smallc.on_qubits(0, 1))

    from qibo.abstractions.callbacks import Callback
    smallc = Circuit(4)
    smallc.add(gates.CallbackGate(Callback()))
    with pytest.raises(NotImplementedError):
        next(smallc.on_qubits(0, 1, 2, 3))
Exemplo n.º 2
0
def test_flatten():
    gate = gates.Flatten([1, 2, 3, 4])
    assert gate.coefficients == [1, 2, 3, 4]
    with pytest.raises(NotImplementedError):
        gate._on_qubits(0, 2)
Exemplo n.º 3
0
def test_circuit_draw_not_supported_gates():
    """Check that ``NotImplementedError`` is raised if gate is not supported."""
    c = Circuit(2)
    c.add(gates.Flatten(1))
    with pytest.raises(NotImplementedError):
        c.draw()
Exemplo n.º 4
0
def test_unknown_gate_error():
    """"Check that using `to_qasm` with not supported gates raises error."""
    c = Circuit(2)
    c.add(gates.Flatten(4 * [0]))
    with pytest.raises(ValueError):
        c.to_qasm()