def test_example(self) -> None: circuit = Circuit(2) circuit.append_gate(HGate(), [0]) assert circuit.find_available_cycle([1]) == 0 circuit.append_gate(XGate(), [0]) circuit.append_gate(ZGate(), [1]) assert circuit.find_available_cycle([1]) == 1
def test_type_invalid_2(self, not_an_location: Sequence[int]) -> None: circuit = Circuit(4, [2, 2, 3, 3]) try: circuit.find_available_cycle(not_an_location) except TypeError: return except BaseException: assert False, 'Unexpected Exception.'
def test_type_valid_1(self, location: Sequence[int]) -> None: circuit = Circuit(1) try: circuit.find_available_cycle(location) except TypeError: assert False, 'Unexpected TypeError.' except BaseException: return
def test(self) -> None: circuit = Circuit(4, [2, 2, 3, 3]) circuit.append_gate(CNOTGate(), [0, 1]) assert circuit.find_available_cycle([2, 3]) == 0 circuit.append_gate( ConstantUnitaryGate(np.identity(36), [2, 2, 3, 3]), [0, 1, 2, 3], ) circuit.append_gate(CNOTGate(), [0, 1]) assert circuit.find_available_cycle([2, 3]) == 2 circuit.append_gate( ConstantUnitaryGate(np.identity(36), [2, 2, 3, 3]), [0, 1, 2, 3], ) circuit.append_gate(CPIGate(), [2, 3]) assert circuit.find_available_cycle([0, 1]) == 4
def test_return_type(self, location: Sequence[int]) -> None: circuit = Circuit(4, [2, 2, 3, 3]) circuit.append_gate(ConstantUnitaryGate(np.identity(2), [2]), [1]) circuit.append_gate( ConstantUnitaryGate(np.identity(36), [2, 2, 3, 3]), [0, 1, 2, 3], ) circuit.append_gate(ConstantUnitaryGate(np.identity(3), [3]), [3]) assert isinstance(circuit.find_available_cycle(location), int)