waves_static

WaveContainer (qurry.qurrium.container.waves_static)

class qurry.qurrium.container.waves_static.WaveContainer(*args, **kwargs)[source]

WaveContainer is a customized dictionary for storing waves.

add(wave: QuantumCircuit, key: Hashable | None = None, replace: Literal[True, False, 'duplicate'] = True) Hashable[source]

Add wave to container.

Parameters:
  • wave (QuantumCircuit) – The wave circuit.

  • key (Optional[Hashable], optional) – The key of wave in ‘fict’ .waves. Defaults to None.

  • replace (Literal[True, False, "duplicate"], optional) – Replace the wave with same key or not. Defaults to True.

Returns:

The key of wave in ‘dict’ .waves.

Return type:

Hashable

Raises:

KeyError – If the wave with same key exists and replace==False.

call(wave: list[Hashable]) list[QuantumCircuit][source]
call(wave: Hashable) QuantumCircuit

Export wave function as QuantumCircuit.

Parameters:

wave (Union[list[Hashable], Hashable]) – The key of wave in ‘dict’ .waves.

Returns:

The circuit of wave function.

Return type:

Union[list[QuantumCircuit], QuantumCircuit]

copy_circuit(wave: list[Hashable] | Hashable) list[QuantumCircuit] | QuantumCircuit[source]

Export a copy of wave function as QuantumCircuit.

Parameters:

wave (Union[list[Hashable], Hashable]) – The key of wave in ‘dict’ .waves.

Returns:

The copy circuit of wave function.

Return type:

Union[list[QuantumCircuit], QuantumCircuit]

gate(wave: list[Hashable] | Hashable) list[Gate] | Gate[source]

Export wave function as Gate.

Parameters:

wave (Union[list[Hashable], Hashable]) – The key of wave in ‘dict’ .waves.

Returns:

The gate of wave function.

Return type:

Union[list[Gate], Gate]

get_wave(wave: list[Hashable], run_by: Literal['gate']) list[Gate][source]
get_wave(wave: list[Hashable], run_by: Literal['operator']) list[Operator]
get_wave(wave: list[Hashable], run_by: Literal['instruction']) list[Instruction]
get_wave(wave: list[Hashable], run_by: Literal['copy', 'call'] | None) list[QuantumCircuit]
get_wave(wave: Hashable, run_by: Literal['gate']) Gate
get_wave(wave: Hashable, run_by: Literal['operator']) Operator
get_wave(wave: Hashable, run_by: Literal['instruction']) Instruction
get_wave(wave: Hashable, run_by: Literal['copy', 'call'] | None) QuantumCircuit

Parse wave Circuit into Instruction as Gate or Operator on QuantumCircuit.

Parameters:
  • wave (Optional[Hashable], optional) – The key of wave in ‘fict’ .waves. Defaults to None.

  • run_by (Optional[str], optional) – Export as Gate, Operator, Instruction or a copy when input is None. Defaults to None.

Raises:
Returns:

Union[

list[Union[Gate, Operator, Instruction, QuantumCircuit]], Union[Gate, Operator, Instruction, QuantumCircuit]

]: The result of the wave as Gate or Operator.

has(wavename: Hashable) bool[source]

Is there a wave with specific name.

Parameters:

wavename (Hashable) – Name of wave which is used in .waves

Returns:

Exist or not.

Return type:

bool

instruction(wave: list[Hashable] | Hashable) list[Instruction] | Instruction[source]

Export wave function as Instruction.

Parameters:

wave (Union[list[Hashable], Hashable]) – The key of wave in ‘dict’ .waves.

Returns:

The instruction of wave function.

Return type:

Union[list[Instruction], Instruction]

operator(wave: list[Hashable] | Hashable) list[Operator] | Operator[source]

Export wave function as Operator.

Parameters:

wave (Union[list[Hashable], Hashable]) – The key of wave in ‘dict’ .waves.

Returns:

The operator of wave function.

Return type:

Union[list[Operator], Operator]

process(circuits: list[QuantumCircuit | Hashable]) list[tuple[Hashable, QuantumCircuit]][source]

Process the circuits in container.

Parameters:

circuits (list[Union[QuantumCircuit, Hashable]]) – The circuits or keys of circuits in container.

Returns:

The processed circuits.

Return type:

list[tuple[Hashable, QuantumCircuit]]

remove(key: Hashable) None[source]

Remove wave from container.

Parameters:

key (Hashable) – The key of wave in ‘dict’ .waves.