Source code for qurry.qurries.string_operator.analysis

"""StringOperator - Analysis (:mod:`qurry.qurries.string_operator.analysis`)"""

from typing import Union, NamedTuple, Iterable, Type
import numpy as np

from .utils import StringOperatorLibType, StringOperatorDirection
from ...qurrium.analysis import AnalysisPrototype


[docs] class SOAnalysisInput(NamedTuple): """To set the analysis."""
[docs] class SOAnalysisContent(NamedTuple): """The content of the analysis.""" order: Union[float, np.float64] """The order of the string operator.""" num_qubits: int """The number of qubits.""" shots: int """The number of shots.""" i: int """The index of beginning qubits in the quantum circuit.""" k: int """The index of ending qubits in the quantum circuit.""" length: int """The length of the string operator, which is k - i + 1.""" str_op: StringOperatorLibType = "i" """The string operator.""" on_dir: StringOperatorDirection = "x" """The direction of the string operator, either 'x' or 'y'."""
[docs] class StringOperatorAnalysis(AnalysisPrototype[SOAnalysisInput, SOAnalysisContent]): """The container for the analysis of :class:`~qurry.qurries.string_operator.experiment.StringOperatorExperiment`.""" __name__ = "SOAnalysis"
[docs] @classmethod def input_type(cls) -> Type[SOAnalysisInput]: """The input instance type.""" return SOAnalysisInput
[docs] @classmethod def content_type(cls) -> Type[SOAnalysisContent]: """The content instance type.""" return SOAnalysisContent
@property def side_product_fields(self) -> Iterable[str]: """The fields that will be stored as side product.""" return []