utils
ยถ
counts_process
ยถ
Recounting counts.
Post Processing - Utils - Counts Process (qurry.process.utils.ccounts_process
)
- qurry.process.utils.counts_process.counts_list_recount(counts_list: list[dict[str, int]], num_classical_register: int, selected_classical_registers_sorted: list[int]) list[dict[str, int]] [source]ยถ
Calculate the counts under the degree.
- Parameters:
- Returns:
The counts under the degree.
- Return type:
- qurry.process.utils.counts_process.counts_list_recount_pyrust(counts_list: list[dict[str, int]], num_classical_register: int, selected_classical_registers_sorted: list[int], backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') list[dict[str, int]] [source]ยถ
Calculate the counts under the degree.
- Parameters:
counts_list (list[dict[str, int]]) โ The list of counts measured from the single quantum circuit.
num_classical_register (int) โ The number of classical registers.
selected_classical_registers_sorted (list[int]) โ The list of the index of the selected_classical_registers.
backend (PostProcessingBackendLabel, optional) โ Backend for the process. Defaults to โRustโ.
- Returns:
The counts under the degree.
- Return type:
- qurry.process.utils.counts_process.counts_list_vectorize_pyrust(counts_list: list[dict[str, int]], backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') list[tuple[list[list[int]], list[int]]] [source]ยถ
Vectorized counts.
- qurry.process.utils.counts_process.rho_m_flatten_counts_list_vectorize_pyrust(counts_list: list[dict[str, int]], random_unitary_um: dict[int, dict[int, Literal[0, 1, 2] | int]], selected_classical_registers_sorted: list[int], backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') list[tuple[list[list[int]], list[int]]] [source]ยถ
Dedicated function for rho_m_flatten counts list vectorized.
- Parameters:
counts_list (list[dict[str, int]]) โ The list of counts measured from the single quantum circuit.
random_unitary_um (dict[int, dict[int, Union[Literal[0, 1, 2], int]]]) โ The shadow direction of the unitary operators.
selected_classical_registers_sorted (list[int]) โ The list of the index of the selected_classical_registers.
- Returns:
The counts under the degree.
- Return type:
- qurry.process.utils.counts_process.shot_counts_selected_clreg_checker_pyrust(shots: int, counts: list[dict[str, int]], selected_classical_registers: int | list[int] | None = None, backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') tuple[int, list[int]] [source]ยถ
Check whether the selected classical registers are valid.
- Parameters:
- Returns:
The size of the subsystem and the selected classical registers.
- Return type:
- qurry.process.utils.counts_process.single_counts_recount(single_counts: dict[str, int], num_classical_register: int, selected_classical_registers_sorted: list[int]) dict[str, int] [source]ยถ
Calculate the counts under the degree.
- Parameters:
- Returns:
The counts under the degree.
- Return type:
- qurry.process.utils.counts_process.single_counts_recount_pyrust(single_counts: dict[str, int], num_classical_register: int, selected_classical_registers_sorted: list[int], backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') dict[str, int] [source]ยถ
Calculate the counts under the degree.
- Parameters:
single_counts (dict[str, int]) โ Counts measured from the single quantum circuit.
num_classical_register (int) โ The number of classical registers.
selected_classical_registers_sorted (list[int]) โ The list of the index of the selected_classical_registers.
backend (PostProcessingBackendLabel, optional) โ Backend for the process. Defaults to โRustโ.
- Returns:
The counts under the degree.
- Return type:
bit_slice
ยถ
bitstring slicing.
Post Processing - Utils - Bit Slice (qurry.process.utils.bit_slice
)
- qurry.process.utils.bit_slice.cycling_slice(target: list[_ItemT], start: int, end: int, step: int = 1) list[_ItemT] [source]ยถ
- qurry.process.utils.bit_slice.cycling_slice(target: tuple[_ItemT], start: int, end: int, step: int = 1) tuple[_ItemT]
- qurry.process.utils.bit_slice.cycling_slice(target: str, start: int, end: int, step: int = 1) str
Slice a iterable object with cycling.
- Parameters:
- Raises:
IndexError โ Slice out of range.
- Returns:
The sliced object.
- Return type:
Iterable
- qurry.process.utils.bit_slice.cycling_slice_rust(target: str, start: int, end: int, step: int = 1) str [source]ยถ
Slice a iterable object with cycling.
- qurry.process.utils.bit_slice.degree_handler(allsystem_size: int, degree: int | tuple[int, int] | None, measure: tuple[int, int] | None) tuple[tuple[int, int], tuple[int, int], int] [source]ยถ
Handle the degree of freedom for the subsystem.
- Parameters:
- Returns:
The degree of freedom, measure range, and subsystem size.
- Return type:
- qurry.process.utils.bit_slice.degree_handler_rust(allsystem_size: int, degree: int | tuple[int, int] | None, measure: tuple[int, int] | None) tuple[tuple[int, int], tuple[int, int], int] [source]ยถ
Handle the degree of freedom for the subsystem.
- Parameters:
- Returns:
The degree of freedom, measure range, and subsystem size.
- Return type:
- qurry.process.utils.bit_slice.is_cycling_slice_active(allsystem_size: int, bitstring_range: tuple[int, int], subsystem_size: int) bool [source]ยถ
Check whether the cycling slice is active.
- qurry.process.utils.bit_slice.qubit_mapper(actual_num_qubits: int, selected_qubits: Sequence[int] | int | tuple[int, int] | None = None) dict[int, int] [source]ยถ
Map the index of selected qubits to the index of the classical register.
- Parameters:
actual_num_qubits (int) โ The actual number of qubits.
selected_qubits (Optional[Union[Sequence[int], int, tuple[int, int]]], optional) โ The selected qubits. If it is None, then it will return the mapping of all qubits. If it is int, then it will return the mapping of the last n qubits. If it is tuple, then it will return the mapping of the qubits in the range. If it is list, then it will return the mapping of the selected qubits.
- Raises:
ValueError โ The range of qubits should be defined by two integers.
ValueError โ The selected qubits are beyond the number of qubits.
ValueError โ The selected qubits are not natural number.
ValueError โ The first integer should be less than the second integer.
ValueError โ The number of selected qubits should be more than 1.
ValueError โ The selected qubits index are beyond the number of qubits.
ValueError โ The selected qubits index are not natural number.
ValueError โ Duplicate selected qubits index are not allowed.
ValueError โ Invalid input for selected qubits.
- Returns:
The mapping of the index of selected qubits to the index of the classical register.
- Return type:
- qurry.process.utils.bit_slice.qubit_mapper_2_int(actual_num_qubits: int, selected_qubits: tuple[int, int]) dict[int, int] [source]ยถ
Map the index of selected qubits to the index of the classical register. The selected qubits are defined by two integers.
- Parameters:
- Raises:
ValueError โ The range of qubits should be defined by two integers.
ValueError โ The selected qubits are beyond the number of qubits.
ValueError โ The selected qubits are not natural number.
ValueError โ The first integer should be less than the second integer.
- Returns:
The mapping of the index of selected qubits to the index of the classical register.
- Return type:
- qurry.process.utils.bit_slice.qubit_selector(num_qubits: int, degree: int | tuple[int, int] | None = None) tuple[int, int] [source]ยถ
Determint the qubits to be used.
- Parameters:
- Raises:
ValueError โ The specific degree of subsystem qubits beyond number of qubits which the wave function has.
ValueError โ The number of qubits of subsystem A is not a natural number.
ValueError โ Invalid input for subsystem range defined by only two integers.
ValueError โ Degree of freedom is not given.
- Returns:
The range of qubits to be used.
- Return type:
- qurry.process.utils.bit_slice.qubit_selector_rust(num_qubits: int, degree: int | tuple[int, int] | None = None) tuple[int, int] [source]ยถ
Determint the qubits to be used.
- Parameters:
- Raises:
ValueError โ The specific degree of subsystem qubits beyond number of qubits which the wave function has.
ValueError โ The number of qubits of subsystem A is not a natural number.
ValueError โ Invalid input for subsystem range defined by only two integers.
ValueError โ Degree of freedom is not given.
- Returns:
The range of qubits to be used.
- Return type:
randomized
ยถ
Peripheral functions for randomized measurement.
Post Processing - Utils - Randomized
(qurry.process.utils.randomized
)
- qurry.process.utils.randomized.ensemble_cell(s_i: str, s_i_meas: int, s_j: str, s_j_meas: int, a_num: int, shots: int) float64 [source]ยถ
Calculate the value of two counts from qubits in ensemble average.
about diff = hamming_distance(sAi, sAj):
It is hamming_distance from qiskit.visualization.count_visualization. Due to frequently update of Qiskit and itโs a simple function, I decide not to use source code instead of calling from qiskit.
- Parameters:
- Returns:
the value of two counts from qubits in ensemble average.
- Return type:
- qurry.process.utils.randomized.ensemble_cell_rust(s_i: str, s_i_meas: int, s_j: str, s_j_meas: int, a_num: int, shots: int) float | float64 [source]ยถ
Calculate the value of two counts from qubits in ensemble average by Rust.
- Parameters:
- Returns:
the value of two counts from qubits in ensemble average.
- Return type:
- qurry.process.utils.randomized.hamming_distance(str1: str, str2: str) int [source]ยถ
Calculate the Hamming distance between two bit strings.
- Parameters:
- Returns:
Distance between strings.
- Return type:
- Raises:
ValueError โ Strings not same length.
dummy
ยถ
Dummy case counts generating.
Post Processing - Utils - Toolkits for Dummy Case
(qurry.process.utils.dummy
)
- qurry.process.utils.dummy.makeTwoBitStrOneLiner(bitlen, bits=[''])ยถ
Make a list of bit strings with length of num. But itโs an ONE LINE code.
- qurry.process.utils.dummy.make_dummy_case(n_a: int, shot_per_case: int, bitstring_num: int | None = None, backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') dict[str, int] [source]ยถ
Make a dummy case for the experiment.
- qurry.process.utils.dummy.make_two_bit_str(bitlen: int, num: int | None = None, backend: Literal['Cython', 'Rust', 'Python'] | str = 'Rust') list[str] [source]ยถ
Make a list of bit strings with length of num.
- qurry.process.utils.dummy.make_two_bit_str_32_py(bitlen: int, num: int | None = None) list[str] [source]ยถ
Make a list of bit strings with length of num.
test
ยถ
Rust binding test function.
Test (qurry.process.utils.test
)
other
ยถ
Remains are not ditributed.
Post Processing - Utils - Other
(qurry.process.utils.other
)
- qurry.process.utils.other.NUMERICAL_ERROR_TOLERANCE = 1e-14ยถ
Tolerance for numerical errors in calculations. This is used to determine if two floating-point numbers are close enough to be considered equal.
The default value is set to 1e-14.