random_unitary
ΒΆ
ToolKits for Random Unitary Operator (qurry.qurrium.utils.random_unitary
)
- qurry.qurrium.utils.random_unitary.check_and_generate_for_single_circ(seed_for_single_circ: int | Generator | Sequence[int | Generator] | dict[int, int | Generator] | None, num_qubits: int) dict[int, int] [source]ΒΆ
Check the input of generate_random_unitary_seeds.
- Parameters:
- Raises:
TypeError β If the seed is not int, np.random.Generator, Sequence, or dict.
ValueError β If the seed for one qubit is not found. If the seed is not int or np.random.Generator. If the length of seed is not equal to num_qubits.
- Returns:
The seed for single circuit.
- Return type:
- qurry.qurrium.utils.random_unitary.check_input_for_experiment(times: int, num_qubits: int, random_unitary_seeds: dict[int, dict[int, int]] | None) None [source]ΒΆ
Check the input of the experiment. If you want to generate the seeds for all random unitary operator, you can use the function generate_random_unitary_seeds in qurry.qurrium.utils.random_unitary.
- Parameters:
times (int) β The number of random unitary operator.
num_qubits (int) β The number of qubits.
random_unitary_seeds (Optional[dict[int, dict[int, int]]]) β The seeds for all random unitary operator. This argument only takes input as type of dict[int, dict[int, int]]. The first key is the index for the random unitary operator. The second key is the index for the qubit.
- Raises:
TypeError β If the random_unitary_seeds is not dict.
ValueError β If the length of random_unitary_seeds is not equal to times.
TypeError β If the random_unitary_seeds[i] is not dict.
ValueError β If the length of random_unitary_seeds[i] is not equal to num_qubits.
TypeError β If the random_unitary_seeds[i][j] is not int.
- qurry.qurrium.utils.random_unitary.generate_random_unitary_seeds(times: int, num_qubits: int, seed: int | Generator | Sequence[int | Generator | Sequence[int | Generator] | dict[int, int | Generator]] | dict[int, int | Generator | Sequence[int | Generator] | dict[int, int | Generator]] | None = None) dict[int, dict[int, int]] [source]ΒΆ
Generate random unitary seeds.
- Parameters:
times (int) β The number of random unitary operator.
num_qubits (int) β The number of qubits.
(Union[ (seed) β
int, np.random.Generator, Sequence[Union[
int, np.random.Generator, Sequence[Union[int, np.random.Generator]], dict[int, Union[int, np.random.Generator]]
]], dict[int, Union[
int, np.random.Generator, Sequence[Union[int, np.random.Generator]], dict[int, Union[int, np.random.Generator]]
]]
] β The seed of random generator.
optional) β The seed of random generator.
- Raises:
TypeError β If the seed is not int, np.random.Generator, Sequence, or dict.
ValueError β If the length of seed is not equal to times.
- Returns:
The random unitary seeds.
- Return type:
- qurry.qurrium.utils.random_unitary.generate_seeds_for_single_circ(seed_for_single_circ: int | Generator | None, num_qubits: int) dict[int, int] [source]ΒΆ
Generate the seed for single circuit.
- Parameters:
seed_for_single_circ (Optional[SeedType]) β The seed for single circuit.
num_qubits (int) β The number of qubits.
- Raises:
ValueError β If the seed is not int, np.random.Generator
- Returns:
The seed for single circuit.
- Return type: