squlearn.qnn.lowlevel_qnn_qiskit.Expec

class squlearn.qnn.lowlevel_qnn_qiskit.Expec(wave_function: str | tuple | ParameterVectorElement, observable: str, label: str = '')

Data structure that holds the set-up of derivative of the expectation value.

Parameters:
  • wave_function (Union[str, tuple, ParameterVectorElement]) – Describes the wave function or its derivative. If tuple or ParameterVectorElement the differentiation with respect to the parameters in the tuple or with respect to the ParameterVectorElement is considered

  • observable (str) – String for the expectation value observable ("O", "OO", "dop", "dopdop", "var").

  • label (str) – Label that is used for displaying or in the value dict of the QNN class.

classmethod from_parameter(val: ParameterVectorElement, operator: str = 'O')

Creates an Expec object from an inputted parameter

Parameters:
  • val (ParameterVectorElement) – Parameter that is used in the differentiation.

  • operator (str) – String for the operator, default=’O’.

Returns

Associated Expec object

classmethod from_parameter_vector(val: ParameterVectorElement, operator: str = 'O')

Creates an Expec object from an inputted parameter

Parameters:
  • val (ParameterVectorElement) – Parameter that is used in the differentiation.

  • operator (str) – String for the operator, default=’O’.

Returns

Associated Expec object

classmethod from_string(val: str)

Converts an input string to the Expec data structure.

Parameters:

derivative (String that defines the expectation value)

Returns:

Associated Expec object

classmethod from_tuple(val: tuple, operator: str = 'O', label=None)

Creates an Expec object from an input tuple

Parameters:
  • val (tuple) – Tuple for the differentiation of the wave function.

  • operator (str) – String for the operator, default=’O’.

Returns

Associated Expec object

classmethod from_variable(val)

Creates an Expec object from an inputted value

Parameters:

val (Union[Expec,str,tuple,ParameterVectorElement]) – value that defines the derivative

Returns

Associated Expec object