def test_empty(self) -> None: circuit = Circuit(1) assert circuit.is_qubit_only() circuit = Circuit(4) assert circuit.is_qubit_only() circuit = Circuit(4, [2, 2, 3, 3]) assert not circuit.is_qubit_only()
def encode(self, circuit: Circuit) -> str: """Write `circuit` in this language.""" if not circuit.is_qubit_only(): raise LangException('Only qubit circuits can be wrriten to qasm.') source = "OPENQASM 2.0;\ninclude \"qelib1.inc\";\n" source += f'qreg q[{circuit.get_size()}];\n' for gate in circuit.get_gate_set(): source += gate.get_qasm_gate_def() for op in circuit: source += op.get_qasm() return source
def test_is_qubit_only(self, simple_circuit: Circuit) -> None: assert simple_circuit.is_qubit_only()
def test_value(self, r6_qudit_circuit: Circuit) -> None: if r6_qudit_circuit.get_radixes().count(2) == 6: assert r6_qudit_circuit.is_qubit_only() else: assert not r6_qudit_circuit.is_qubit_only()
def test_type(self, r6_qudit_circuit: Circuit) -> None: assert isinstance(r6_qudit_circuit.is_qubit_only(), bool)
def test_is_qubit_only(self, toffoli_circuit: Circuit) -> None: assert toffoli_circuit.is_qubit_only()
def test_is_qubit_only(self, swap_circuit: Circuit) -> None: assert swap_circuit.is_qubit_only()
def test_r3_con_radix(self, r3_qubit_constant_circuit: Circuit) -> None: assert r3_qubit_constant_circuit.is_qubit_only()