Portuguese
Idiomas
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.pulse.ScheduleBlock.assign_references

ScheduleBlock.assign_references(subroutine_dict, inplace=True)[código fonte]

Assign schedules to references.

It is only capable of assigning a schedule block to immediate references which are directly referred within the current scope. Let’s see following example:

from qiskit import pulse

with pulse.build() as subroutine:
    pulse.delay(10, pulse.DriveChannel(0))

with pulse.build() as sub_prog:
    pulse.reference("A")

with pulse.build() as main_prog:
    pulse.reference("B")

In above example, the main_prog can refer to the subroutine «root::B» and the reference of «B» to program «A», i.e., «B::A», is not defined in the root namespace. This prevents breaking the reference «root::B::A» by the assignment of «root::B». For example, if a user could indirectly assign «root::B::A» from the root program, one can later assign another program to «root::B» that doesn’t contain «A» within it. In this situation, a reference «root::B::A» would still live in the reference manager of the root. However, the subroutine «root::B::A» would no longer be used in the actual pulse program. To assign subroutine «A» to nested_prog as a nested subprogram of main_prog, you must first assign «A» of the sub_prog, and then assign the sub_prog to the main_prog.

sub_prog.assign_references({("A", ): nested_prog}, inplace=True)
main_prog.assign_references({("B", ): sub_prog}, inplace=True)

Alternatively, you can also write

main_prog.assign_references({("B", ): sub_prog}, inplace=True)
main_prog.references[("B", )].assign_references({"A": nested_prog}, inplace=True)

Here references returns a dict-like object, and you can mutably update the nested reference of the particular subroutine.

Nota

Assigned programs are deep-copied to prevent an unexpected update.

Parâmetros
  • subroutine_dict (Dict[Union[str, Tuple[str, ...]], ScheduleBlock]) – A mapping from reference key to schedule block of the subroutine.

  • inplace (bool) – Set True to override this instance with new subroutine.

Tipo de retorno

ScheduleBlock

Retorno

Schedule block with assigned subroutine.

Levanta

PulseError – When reference key is not defined in the current scope.