from qoqo import Circuit from typing import List @pytest.mark.parametrize('measurement', [ (ops.MeasureQubit(qubit=0, readout='ro', readout_index=0), int, 0), (ops.PragmaRepeatedMeasurement(readout='ro', number_measurements=10), int, 0), (ops.PragmaGetPauliProduct( qubit_paulis={ 0: 1, 1: 2 }, readout='ro', circuit=Circuit()), float, 1), (ops.PragmaGetOccupationProbability(readout='ro', circuit=Circuit()), float, 1), (ops.PragmaGetStateVector(readout='ro', circuit=Circuit()), complex, 2), (ops.PragmaGetDensityMatrix(readout='ro', circuit=Circuit()), complex, 2), ]) def test_circuit(measurement): """Test building a circuit""" circuit = Circuit() circuit += ops.DefinitionFloat(name='ro', length=1, is_output=True) circuit += ops.DefinitionComplex(name='ro', length=1, is_output=True) circuit += ops.DefinitionBit(name='ro', length=1, is_output=True) circuit += ops.PauliX(qubit=0) circuit += measurement[0] assert len(circuit) > 0 if __name__ == '__main__': pytest.main(sys.argv)
ops.PragmaDamping(0, 0.005, 0.02), ops.PragmaDephasing(0, 0.005, 0.02), ops.PragmaDepolarising(0, 0.005, 0.02), ops.PragmaRandomNoise(0, 0.005, 0.02, 0.01), ops.PragmaGeneralNoise( 0, 0.005, np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=float)), ops.PragmaConditional('ro', 0, Circuit()), ops.PragmaRepeatGate(3), ops.PragmaBoostNoise(0.004), ops.PragmaStopParallelBlock([0, 1], 0.002), ops.PragmaSleep([0, 1], 0.002), ops.PragmaActiveReset(0), ops.PragmaGlobalPhase(0.03), ops.MeasureQubit(0, 'ro', 0), ops.PragmaRepeatedMeasurement('ro', 20, {}), ops.PragmaGetStateVector('ro', Circuit()), ops.PragmaGetDensityMatrix('ro', Circuit()), ops.PragmaGetOccupationProbability('ro', Circuit()), ops.PragmaGetPauliProduct({}, 'ro', Circuit()), ops.PragmaStartDecompositionBlock([0, 1], {}), ops.PragmaStopDecompositionBlock([0, 1]), ops.InputSymbolic('other', 0), ]) def test_all_operations(op: Any): """Test all operations with mocked interface""" circuit = Circuit() circuit += ops.DefinitionFloat(name='ro', length=1, is_output=False) circuit += ops.DefinitionBit(name='ro', length=1, is_output=False) circuit += ops.DefinitionComplex(name='ro', length=1, is_output=False) circuit += ops.DefinitionUsize(name='ro', length=1, is_output=False) circuit += op