def test_partial_non_result(): Program( instructions=[CNot(control=0, target=1)], results=[ Expectation(targets=[1], observable=["x"]), CNot(control=0, target=1) ], )
def test_cnot_getters(): control = 0 target = 2 cnot = CNot(control=control, target=target) assert cnot.control == control assert cnot.target == target assert cnot.type == CNot.Type.cnot
def test_partial_non_rotation_basis_instruction(): Program( instructions=[CNot(control=0, target=1)], basis_rotation_instructions=[ Expectation(targets=[1], observable=["x"]), H(target=1) ], )
def test_cnot_enum_type(): cnot = CNot(type="cnot", control=0, target=1) assert cnot.type == CNot.Type.cnot
def test_cnot_string_type(): cnot = CNot(type=CNot.Type.cnot, control=0, target=1) assert cnot.type == CNot.Type.cnot
def program(): return Program(instructions=[CNot(control=0, target=1)])
def test_rotation_basis_instruction(): Program(instructions=[CNot(control=0, target=1)], basis_rotation_instructions=[H(target=1)])
def test_instruction_with_results(): Program( instructions=[CNot(control=0, target=1)], results=[Expectation(targets=[1], observable=["x"])], )
def test_instruction_no_results(): program = Program(instructions=[CNot(control=0, target=1)]) assert Program.parse_raw(program.json()) == program
def test_partial_non_instruction(): Program(instructions=[CNot(control=0, target=1), "foo"])