py_alqorithms.measure_spin_operator

py_alqorithms.measure_spin_operator(input_operator, constant_circuit, name, undo_basis_rotation, number_measurements, qubit_mapping=None, definitionbit_length=None)

Take a PauliOperator/PauliHamiltonian and apply an optimised PauliZ-basis measurement of all of the terms in it.

Parameters:
  • input_operator (PauliOperator) -- The PauliOperator/PauliHamiltonian to be measured

  • constant_circuit (Optional[Circuit]) -- Optional circuit to apply to all parts of the measurement, before the measurement circuits

  • name (str) -- Name of the measured operator

  • undo_basis_rotation (bool) -- Optional append operations undoing basis rotations

  • number_measurements (Optional[int]) -- Optional number of measurements. If None, the code will perform a single measurement circuit. If x, the code will perform x repeated measurements of the measurement circuit.

  • qubit_mapping (Optional[Dict[int, int]]) -- Optional qubit mapping to be applied in the measurement circuit.

  • definitionbit_length (Optional[int]) -- Optional length to set for the DefinitionBit operation.

Returns:

The PauliZProduct measurement struct populated with the circuits and inputs corresponding to the SpinOperator given

Return type:

PauliZProduct

Raises:
  • PyTypeError -- Could not convert input_operator to PauliOperator.

  • PyTypeError -- Could not convert constant_circuit to Circuit.

  • PyValueError -- Issue in the add_operator_product function in struqture

  • PyValueError -- Issue in the float function in qoqo_calculator

  • PyValueError -- Length of PauliProduct exceeds length of measurement register

  • PyValueError -- The two PauliProducts given are incompatible

  • PyValueError -- Issue in the add_pauliz_product function in roqoqo

  • PyValueError -- The name of expectation value is already taken