def test_add_result_type_observable_conflict_different_selected_targets_then_all_target( ): circ = Circuit().add_result_type( ResultType.Expectation(observable=Observable.Z(), target=[0])) circ.add_result_type( ResultType.Expectation(observable=Observable.Y(), target=[1])) circ.add_result_type(ResultType.Expectation(observable=Observable.Y()))
def test_add_result_type_observable_conflict_different_selected_targets_then_all_target( ): circ = Circuit().add_result_type( ResultType.Expectation(observable=Observable.Z(), target=[0])) circ.add_result_type( ResultType.Expectation(observable=Observable.Y(), target=[1])) circ.add_result_type(ResultType.Expectation(observable=Observable.Y())) assert not circ.observables_simultaneously_measurable assert not circ.basis_rotation_instructions
def convert_experiment(experiment: QasmQobjExperiment) -> Circuit: qc = Circuit() qasm_obj_instruction: QasmQobjInstruction for qasm_obj_instruction in experiment.instructions: name = qasm_obj_instruction.name if name == 'measure': qc.add_result_type(result_types.Probability(qasm_obj_instruction.qubits)) elif name == 'barrier': # This does not exist pass else: params = [] if hasattr(qasm_obj_instruction, 'params'): params = qasm_obj_instruction.params gates: List[Gate] = _qiskit_2_braket_conversion[name](*params) for gate in gates: instruction = Instruction(operator=gate, target=qasm_obj_instruction.qubits) qc += instruction return qc
def test_add_result_type_observable_conflict_selected_target_then_all_target(): circ = Circuit().add_result_type( ResultType.Expectation(observable=Observable.Y(), target=[0, 1])) circ.add_result_type(ResultType.Probability())
def test_add_result_type_observable_conflict_all(): circ = Circuit().add_result_type(ResultType.Probability()) circ.add_result_type(ResultType.Expectation(observable=Observable.Y()))
def test_add_result_type_observable_conflict_all(): circ = Circuit().add_result_type(ResultType.Probability()) circ.add_result_type(ResultType.Expectation(observable=Observable.Y())) assert not circ.observables_simultaneously_measurable assert not circ.basis_rotation_instructions