string_operator

StringOperator - String Operator (qurry.qurries.string_operator)

Formerly known as qurstrop

Reference:

Note

  • Crossing a topological phase transition with a quantum computer -

Smith, Adam and Jobst, Bernhard and Green, Andrew G. and Pollmann, Frank, [PhysRevResearch.4.L022020](https://link.aps.org/doi/10.1103/PhysRevResearch.4.L022020)

arguments

StringOperator - Arguments (qurry.qurries.string_operator.arguments)

class qurry.qurries.string_operator.arguments.StringOperatorAnalyzeArgs[source]

The input of the analyze method.

class qurry.qurries.string_operator.arguments.StringOperatorArguments(exp_name: str, num_qubits: int, i: int, k: int, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x')[source]

Arguments for the experiment.

exp_name: str

The name of the experiment. Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to ‘experiment’.

i: int

The index of beginning qubits in the quantum circuit.

k: int

The index of ending qubits in the quantum circuit.

num_qubits: int

The number of qubits.

on_dir: Literal['x', 'y'] = 'x'

The direction of the string operator, either ‘x’ or ‘y’.

str_op: Literal['i', 'zy'] = 'i'

The string operator.

class qurry.qurries.string_operator.arguments.StringOperatorMeasureArgs[source]

Output arguments for output().

i: int | None

The index of beginning qubits in the quantum circuit.

k: int | None

The index of ending qubits in the quantum circuit.

on_dir: Literal['x', 'y']

The direction of the string operator, either ‘x’ or ‘y’.

str_op: Literal['i', 'zy']

The string operator.

wave: QuantumCircuit | Hashable | None

The key or the circuit to execute.

class qurry.qurries.string_operator.arguments.StringOperatorOutputArgs[source]

Output arguments for output().

i: int | None

The index of beginning qubits in the quantum circuit.

k: int | None

The index of ending qubits in the quantum circuit.

on_dir: Literal['x', 'y']

The direction of the string operator, either ‘x’ or ‘y’.

str_op: Literal['i', 'zy']

The string operator.

analysis

StringOperator - Analysis (qurry.qurries.string_operator.analysis)

class qurry.qurries.string_operator.analysis.SOAnalysisContent(order: float | float64, num_qubits: int, shots: int, i: int, k: int, length: int, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x')[source]

The content of the analysis.

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.

num_qubits: int

The number of qubits.

on_dir: Literal['x', 'y']

The direction of the string operator, either ‘x’ or ‘y’.

order: float | float64

The order of the string operator.

shots: int

The number of shots.

str_op: Literal['i', 'zy']

The string operator.

class qurry.qurries.string_operator.analysis.SOAnalysisInput[source]

To set the analysis.

class qurry.qurries.string_operator.analysis.StringOperatorAnalysis(*, serial: int, log: dict[str, Any] | None = None, datatime: str | None = None, **other_kwargs)[source]

The container for the analysis of :cls:`StringOperatorExperiment`.

classmethod content_type() Type[SOAnalysisContent][source]

The content instance type.

classmethod input_type() Type[SOAnalysisInput][source]

The input instance type.

property side_product_fields: Iterable[str]

The fields that will be stored as side product.

utils

String Operator - Utilities (qurry.qurries.string_operator.utils)

qurry.qurries.string_operator.utils.STRING_OPERATOR: dict[Literal['x', 'y'], StringOperatorLib] = {'x': {'i': {'filling': ('ry', -1.5707963267948966), -1: None, 0: None}, 'zy': {'filling': ('ry', -1.5707963267948966), -1: ('rz', 0), -2: ('rx', 1.5707963267948966), 0: ('rz', 0), 1: ('rx', 1.5707963267948966)}}, 'y': {'i': {'filling': ('rx', 1.5707963267948966), -1: None, 0: None}, 'zy': {'filling': ('rx', 1.5707963267948966), -1: ('rz', 0), -2: ('ry', -1.5707963267948966), 0: ('rz', 0), 1: ('ry', -1.5707963267948966)}}}

Available string operator library.

  • “x”: Available string operator library for the X direction.

  • “y”: Available string operator library for the Y direction.

\[S^O(g) = \langle\psi|\hat{O_i} \left(\prod_{j = i+2}^{k-2} \hat{\sigma}_j^x \right) \hat{O_i}|\psi\rangle\]
  • i: When \(\hat{O_i} = \hat{O'_k} = \mathbb{1}\),

denoted as \(S^{\mathbb{1}}(g)\), i for identity operator.

  • zy: When \(\hat{O_i} = \hat{\sigma}_i^z\hat{\sigma}_{i+1}^y\) and

\(\hat{O'_i} = \hat{\sigma}_{k-1}^y\hat{\sigma}_k^y\), denoted as \(S^{\sigma^{zy}}(g)\) for ZY operator.

qurry.qurries.string_operator.utils.StringOperatorDirection

Available string operator directions. - “x”: String operator in the X direction. - “y”: String operator in the Y direction.

alias of Literal[‘x’, ‘y’]

class qurry.qurries.string_operator.utils.StringOperatorLib[source]

String Operator Library.

Which is defined by following the equation:

\[S^O(g) = \langle\psi|\hat{O_i} \left(\prod_{j = i+2}^{k-2} \hat{\sigma}_j^x \right) \hat{O_i}|\psi\rangle\]
  • i: When \(\hat{O_i} = \hat{O'_k} = \mathbb{1}\),

denoted as \(S^{\mathbb{1}}(g)\), i for identity operator.

  • zy: When \(\hat{O_i} = \hat{\sigma}_i^z\hat{\sigma}_{i+1}^y\) and

\(\hat{O'_i} = \hat{\sigma}_{k-1}^y\hat{\sigma}_k^y\), denoted as \(S^{\sigma^{zy}}(g)\) for ZY operator.

i: dict[int | Literal['filling'], tuple[Literal['rx', 'ry', 'rz'], float] | None]

Identity string operator.

\[\hat{O_i} = \hat{O'_k} = \mathbb{1}\]
zy: dict[int | Literal['filling'], tuple[Literal['rx', 'ry', 'rz'], float] | None]

ZY string operator.

\[\hat{O'_i} = \hat{\sigma}_{k-1}^y\hat{\sigma}_k^y, \hat{O'_i} = \hat{\sigma}_{k-1}^y\hat{\sigma}_k^y\]
qurry.qurries.string_operator.utils.StringOperatorLibType

Available string operator types. - “i”: Identity string operator. - “zy”: ZY string operator.

alias of Literal[‘i’, ‘zy’]

qurry.qurries.string_operator.utils.StringOperatorUnits

Available string operator units.

  • tuple[Literal[“rx”, “ry”, “rz”], float]: A tuple containing:
    • “rx”: Rotation around the x-axis.

    • “ry”: Rotation around the y-axis.

    • “rz”: Rotation around the z-axis.

    • float: The angle of rotation in radians.

    and do the measurement on the qubit.

  • None: No operation and measurement is performed on the qubit.

alias of tuple[Literal[‘rx’, ‘ry’, ‘rz’], float] | None

qurry.qurries.string_operator.utils.circuit_method(target_circuit: QuantumCircuit, target_key: str, i: int, k: int, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x') QuantumCircuit[source]

Build the circuit for the experiment.

Parameters:
  • target_circuit (QuantumCircuit) – Target circuit.

  • target_key (str) – Target key.

  • i (int) – The index of beginning qubits in the quantum circuit.

  • k (int) – The index of ending qubits in the quantum circuit.

  • str_op (StringOperatorLibType) – The string operator.

  • on_dir (StringOperatorDirection) – The direction of the string operator, either “x” or “y”.

Returns:

The circuit for the experiment.

Return type:

QuantumCircuit

experiment

StringOperator - Experiment (qurry.qurries.string_operator.experiment)

class qurry.qurries.string_operator.experiment.StringOperatorExperiment(arguments: _A | dict[str, Any], commonparams: Commonparams | dict[str, Any], outfields: dict[str, Any], beforewards: Before | None = None, afterwards: After | None = None, reports: AnalysesContainer | None = None)[source]

The instance of experiment.

property analysis_instance: Type[StringOperatorAnalysis]

The analysis instance for this experiment.

analyze(pbar: tqdm | None = None) StringOperatorAnalysis[source]

Calculate magnet square with more information combined.

Parameters:

pbar (Optional[tqdm.tqdm], optional) – The progress bar. Defaults to None.

Returns:

The result of the analysis.

Return type:

StringOperatorAnalysis

property arguments_instance: Type[StringOperatorArguments]

The arguments instance for this experiment.

classmethod method(targets: list[tuple[Hashable, QuantumCircuit]], arguments: StringOperatorArguments, pbar: tqdm | None = None, multiprocess: bool = True) tuple[list[QuantumCircuit], dict[str, Any]][source]

The method to construct circuit.

Parameters:
  • targets (list[tuple[Hashable, QuantumCircuit]]) – The circuits of the experiment.

  • arguments (StringOperatorArguments) – The arguments of the experiment.

  • pbar (Optional[tqdm.tqdm], optional) – The progress bar for showing the progress of the experiment. Defaults to None.

  • multiprocess (bool, optional) – Whether to use multiprocessing. Defaults to True.

Returns:

The circuits of the experiment and the side products.

Return type:

tuple[list[QuantumCircuit], dict[str, Any]]

classmethod params_control(targets: list[tuple[Hashable, QuantumCircuit]], exp_name: str = 'exps', i: int | None = None, k: int | None = None, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x', **custom_kwargs: Any) tuple[StringOperatorArguments, Commonparams, dict[str, Any]][source]

Handling all arguments and initializing a single experiment.

Parameters:
  • targets (list[tuple[Hashable, QuantumCircuit]]) – The circuits of the experiment.

  • exp_name (str, optional) – The name of the experiment. Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to ‘exps’.

  • i (Optional[int], optional) – The index of beginning qubits in the quantum circuit.

  • k (Optional[int], optional) – The index of ending qubits in the quantum circuit.

  • str_op (StringOperatorLibType, optional) – The string operator. Defaults to “i”.

  • on_dir (StringOperatorDirection, optional) – The direction of the string operator, either ‘x’ or ‘y’. Defaults to “x”.

  • custom_kwargs (Any) – The custom parameters.

Returns:

The arguments of the experiment, the common parameters, and the custom parameters.

Return type:

tuple[StringOperatorArguments, Commonparams, dict[str, Any]]

classmethod quantities(shots: int | None = None, counts: list[dict[str, int]] | None = None, backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust', pbar: tqdm | None = None) StringOperator[source]

Calculate the string operator.

Parameters:
  • shots (int) – The number of shots.

  • counts (list[dict[str, int]]) – The counts of the experiment.

  • backend (PostProcessingBackendLabel, optional) – The backend label. Defaults to DEFAULT_PROCESS_BACKEND.

  • pbar (Optional[tqdm.tqdm], optional) – The progress bar. Defaults to None.

Returns:

The result of the magnet square.

Return type:

StringOperator

qurry

StringOperator - Qurrium (qurry.qurries.string_operator.qurry)

class qurry.qurries.string_operator.qurry.StringOperator[source]

String Operator Order

Reference:

Note

  • Crossing a topological phase transition with a quantum computer -

Smith, Adam and Jobst, Bernhard and Green, Andrew G. and Pollmann, Frank, [PhysRevResearch.4.L022020](https://link.aps.org/doi/10.1103/PhysRevResearch.4.L022020)

property experiment_instance: Type[StringOperatorExperiment]

The container class responding to this Qurrium class.

measure(wave: QuantumCircuit | Hashable | None = None, i: int | None = None, k: int | None = None, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x', shots: int = 1024, backend: Backend | None = None, exp_name: str = 'experiment', run_args: BaseRunArgs | dict[str, Any] | None = None, transpile_args: TranspileArgs | None = None, passmanager: str | PassManager | tuple[str, PassManager] | None = None, tags: tuple[str, ...] | None = None, qasm_version: Literal['qasm2', 'qasm3'] = 'qasm3', export: bool = False, save_location: Path | str | None = None, pbar: tqdm | None = None) str[source]

Execute the experiment.

Parameters:
  • wave (Union[QuantumCircuit, Hashable]) – The key or the circuit to execute.

  • i (Optional[int], optional) – The index of beginning qubits in the quantum circuit.

  • k (Optional[int], optional) – The index of ending qubits in the quantum circuit.

  • str_op (StringOperatorLibType, optional) – The string operator. Defaults to “i”.

  • on_dir (StringOperatorDirection, optional) – The direction of the string operator, either ‘x’ or ‘y’. Defaults to “x”.

  • shots (int, optional) – Shots of the job. Defaults to 1024.

  • backend (Optional[Backend], optional) – The quantum backend. Defaults to None.

  • exp_name (str, optional) – The name of the experiment. Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to ‘exps’.

  • run_args (RunArgsType, optional) – Arguments for Backend.run(). Defaults to None.

  • transpile_args (Optional[TranspileArgs], optional) – Arguments of transpile() from qiskit.compiler.transpiler. Defaults to None.

  • passmanager (Optional[Union[str, PassManager, tuple[str, PassManager]], optional) – The passmanager. Defaults to None.

  • tags (Optional[tuple[str, ...]], optional) – The tags of the experiment. Defaults to None.

  • qasm_version (Literal["qasm2", "qasm3"], optional) – The version of OpenQASM. Defaults to “qasm3”.

  • export (bool, optional) – Whether to export the experiment. Defaults to False.

  • save_location (Optional[Union[Path, str]], optional) – The location to save the experiment. Defaults to None.

  • pbar (Optional[tqdm.tqdm], optional) – The progress bar for showing the progress of the experiment. Defaults to None.

Returns:

The ID of the experiment

Return type:

str

measure_to_output(wave: QuantumCircuit | Hashable | None = None, i: int | None = None, k: int | None = None, str_op: Literal['i', 'zy'] = 'i', on_dir: Literal['x', 'y'] = 'x', shots: int = 1024, backend: Backend | None = None, exp_name: str = 'experiment', run_args: BaseRunArgs | dict[str, Any] | None = None, transpile_args: TranspileArgs | None = None, passmanager: str | PassManager | tuple[str, PassManager] | None = None, tags: tuple[str, ...] | None = None, qasm_version: Literal['qasm2', 'qasm3'] = 'qasm3', export: bool = False, save_location: Path | str | None = None, pbar: tqdm | None = None) StringOperatorOutputArgs[source]

Trasnform measure() arguments form into output() form.

Parameters:
  • wave (Union[QuantumCircuit, Hashable]) – The key or the circuit to execute.

  • i (Optional[int], optional) – The index of beginning qubits in the quantum circuit.

  • k (Optional[int], optional) – The index of ending qubits in the quantum circuit.

  • str_op (StringOperatorLibType, optional) – The string operator. Defaults to “i”.

  • on_dir (StringOperatorDirection, optional) – The direction of the string operator, either ‘x’ or ‘y’. Defaults to “x”.

  • shots (int, optional) – Shots of the job. Defaults to 1024.

  • backend (Optional[Backend], optional) – The quantum backend. Defaults to None.

  • exp_name (str, optional) – The name of the experiment. Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to ‘exps’.

  • run_args (RunArgsType, optional) – Arguments for Backend.run(). Defaults to None.

  • transpile_args (Optional[TranspileArgs], optional) – Arguments of transpile() from qiskit.compiler.transpiler. Defaults to None.

  • passmanager (Optional[Union[str, PassManager, tuple[str, PassManager]], optional) – The passmanager. Defaults to None.

  • tags (Optional[tuple[str, ...]], optional) – The tags of the experiment. Defaults to None.

  • qasm_version (Literal["qasm2", "qasm3"], optional) – The version of OpenQASM. Defaults to “qasm3”.

  • export (bool, optional) – Whether to export the experiment. Defaults to False.

  • save_location (Optional[Union[Path, str]], optional) – The location to save the experiment. Defaults to None.

  • pbar (Optional[tqdm.tqdm], optional) – The progress bar for showing the progress of the experiment. Defaults to None.

Returns:

The output arguments.

Return type:

StringOperatorOutputArgs

short_name = 'qurstrop_string_operator'

The short name of Qurrium.