Skip to content

Field

Field

Bases: FieldExpr

Field node in the IR. Which contains collection(s) of Waveform

<field> ::= ('field' <spatial modulation>  <padded waveform>)*

canonicalize

canonicalize()

Canonicalize the Field by merging ScaledLocation nodes with the same waveform.

Source code in src/bloqade/ir/control/field.py
def canonicalize(self) -> "Field":
    """
    Canonicalize the Field by merging `ScaledLocation` nodes with the same waveform.
    """
    reversed_dirves = {}

    for sm, wf in self.drives.items():
        reversed_dirves[wf] = reversed_dirves.get(wf, []) + [sm]

    drives = {}

    for wf, sms in reversed_dirves.items():
        new_sm = [sm for sm in sms if not isinstance(sm, ScaledLocations)]
        scaled_locations_sm = [sm for sm in sms if isinstance(sm, ScaledLocations)]

        new_mask = {}

        for ele in scaled_locations_sm:
            for loc, scl in ele.value.items():
                new_mask[loc] = new_mask.get(loc, 0) + cast(scl)

        if new_mask:
            new_sm += [ScaledLocations(new_mask)]

        for sm in new_sm:
            drives[sm] = wf

    return Field(drives)

show

show(**assignments)

Interactive visualization of the Field

Parameters:

Name Type Description Default
**assignments

assigning the instance value (literal) to the existing variables in the Field

{}
Source code in src/bloqade/ir/control/field.py
def show(self, **assignments):
    """
    Interactive visualization of the Field

    Args:
        **assignments: assigning the instance value (literal) to the
            existing variables in the Field

    """
    display_ir(self, assignments)