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))
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)
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()
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()