diff --git a/src/bloqade/builder/location.py b/src/bloqade/builder/location.py index 6a16e0e9d..537531962 100644 --- a/src/bloqade/builder/location.py +++ b/src/bloqade/builder/location.py @@ -15,34 +15,7 @@ def __init__(self, parent: Builder, label: int) -> None: def scale(self, scale: float): """ - - Scale the preceeding waveform by the specified factor. - - Possible Next : - - -> `...location(int).location(int)` - :: keep adding location into current list - - - Possible Next : - - -> `...location(int).linear()` - :: apply linear waveform - - -> `...location(int).constant()` - :: apply constant waveform - - -> `...location(int).ploy()` - :: apply polynomial waveform - - -> `...location(int).apply()` - :: apply pre-constructed waveform - - -> `...location(int).piecewise_linear()` - :: apply piecewise linear waveform - - -> `...location(int).piecewise_constant()` - :: apply piecewise constant waveform - - -> `...location(int).fn()` - :: apply callable as waveform. + Scale the preceeding waveform by the specified factor. Args: scale (float): The factor to scale (amplitude of) @@ -67,6 +40,37 @@ def scale(self, scale: float): >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) >>> scaled = reg.rydberg.detuning.location(0).location(1).scale(1.2) + + - Possible Next : + + -> `...scale(float).location(int)` + :: keep adding location into current list + + - Possible Next : + + -> `...scale(float).linear()` + :: apply linear waveform + + -> `...scale(float).constant()` + :: apply constant waveform + + -> `...scale(float).ploy()` + :: apply polynomial waveform + + -> `...scale(float).apply()` + :: apply pre-constructed waveform(s) + + -> `...scale(float).piecewise_linear()` + :: apply piecewise linear waveform + + -> `...scale(float).piecewise_constant()` + :: apply piecewise constant waveform + + -> `...scale(float).fn()` + :: apply callable as waveform. + + + """ return Scale(self, scale) @@ -74,13 +78,31 @@ def location(self, label: int): """ Append another location to the current location(s) + Args: + label (int): The label of the location + + Examples: + + - Append location 1 to the current location 0. + + >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) + >>> loc = reg.rydberg.detuning.location(0) + >>> loc = loc.location(1) + + - One can keep appending by concatenating location() + + >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) + >>> loc = reg.rydberg.detuning.location(0) + >>> loc = loc.location(1).location(2) + - Possible Next : -> `...location(int).location(int)` :: keep adding location into current list -> `...location(int).scale(float)` - :: specify scaling factor for the preceeding waveform + :: specify scaling factor to current location + for the preceeding waveform - Possible Next : @@ -105,22 +127,6 @@ def location(self, label: int): -> `...location(int).fn()` :: apply callable as waveform. - Args: - label (int): The label of the location - - Examples: - - - Append location 1 to the current location 0. - - >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) - >>> loc = reg.rydberg.detuning.location(0) - >>> loc = loc.location(1) - - - One can keep appending by concatenating location() - - >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) - >>> loc = reg.rydberg.detuning.location(0) - >>> loc = loc.location(1).location(2) """ return Location(self, label) @@ -134,11 +140,27 @@ def __init__(self, parent: Builder, scale) -> None: def location(self, label: int): """ - Append another location to the current location after scale the previous one + + Args: + label (int): The label of the location + + Examples: + + - Append location 1 after scale location 0 by 1.2. + + >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) + >>> loc = reg.rydberg.detuning.location(0).scale(1.2) + >>> loc = loc.location(1) + - Possible Next : -> `...location(int).location(int)` :: keep adding location into current list + -> `...location(int).scale(float)` + :: specify scaling factor to current location + for the preceeding waveform + - Possible Next : -> `...location(int).linear()` @@ -163,16 +185,6 @@ def location(self, label: int): :: apply callable as waveform. - Args: - label (int): The label of the location - - Examples: - - - Append location 1 after scale location 0 by 1.2. - - >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) - >>> loc = reg.rydberg.detuning.location(0).scale(1.2) - >>> loc = loc.location(1) """ return Location(self, label) diff --git a/src/bloqade/builder/spatial.py b/src/bloqade/builder/spatial.py index d06fe36ad..8c69f406b 100644 --- a/src/bloqade/builder/spatial.py +++ b/src/bloqade/builder/spatial.py @@ -11,14 +11,37 @@ class SpatialModulation(Builder): def location(self, label: int): """ - - Addressing one or multiple specific location(s) for preceeding waveform. + Addressing one or multiple specific location(s) for preceeding waveform. + + (See [`Location`][bloqade.builder.location.Location] for more details]) + + Args: + label (int): The label of the location to apply the following waveform to. + + Examples: + + - Addressing rydberg detuning to location 1 on a system with 4 sites. + + >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) + >>> loc = reg.rydberg.detuning.location(1) + + - Addressing rydberg detuning on both location + 0 and 2 on a system with 4 sites. + + >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) + >>> loc = reg.rydberg.detuning.location(1).location(2) + + Note: + label index start with 0, and should be positive. + - Possible Next : -> `...location(int).location(int)` :: adding location into current list -> `...location(int).scale(float)` - :: specify scaling factor for the preceeding waveform + :: specify scaling factor to current location + for the preceeding waveform - Possible Next : @@ -44,29 +67,6 @@ def location(self, label: int): :: apply callable as waveform. - (See [`Location`][bloqade.builder.location.Location] for more details]) - - Args: - label (int): The label of the location to apply the following waveform to. - - Examples: - - - Addressing rydberg detuning to location 1 on a system with 4 sites. - - >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) - >>> loc = reg.rydberg.detuning.location(1) - - - Addressing rydberg detuning on both location - 0 and 2 on a system with 4 sites. - - >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)]) - >>> loc = reg.rydberg.detuning.location(1).location(2) - - - Note: - label index start with 0, and should be positive. - - """ from .location import Location diff --git a/src/bloqade/builder/waveform.py b/src/bloqade/builder/waveform.py index 1e2dd691c..d6bcd3a86 100644 --- a/src/bloqade/builder/waveform.py +++ b/src/bloqade/builder/waveform.py @@ -28,8 +28,7 @@ def linear(self, start: ScalarType, stop: ScalarType, duration: ScalarType): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -41,6 +40,8 @@ def linear(self, start: ScalarType, stop: ScalarType, duration: ScalarType): - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -58,10 +59,10 @@ def linear(self, start: ScalarType, stop: ScalarType, duration: ScalarType): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel - Possible Next : @@ -106,8 +107,7 @@ def constant(self, value: ScalarType, duration: ScalarType): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -119,6 +119,8 @@ def constant(self, value: ScalarType, duration: ScalarType): - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -136,10 +138,10 @@ def constant(self, value: ScalarType, duration: ScalarType): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel - Possible Next : @@ -189,8 +191,7 @@ def poly(self, coeffs: ScalarType, duration: ScalarType): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -202,6 +203,8 @@ def poly(self, coeffs: ScalarType, duration: ScalarType): - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -219,10 +222,11 @@ def poly(self, coeffs: ScalarType, duration: ScalarType): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -268,8 +272,7 @@ def apply(self, wf: ir.Waveform): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -281,6 +284,8 @@ def apply(self, wf: ir.Waveform): - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -298,10 +303,11 @@ def apply(self, wf: ir.Waveform): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -355,8 +361,7 @@ def piecewise_linear(self, durations: List[ScalarType], values: List[ScalarType] - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -368,6 +373,8 @@ def piecewise_linear(self, durations: List[ScalarType], values: List[ScalarType] - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -385,10 +392,11 @@ def piecewise_linear(self, durations: List[ScalarType], values: List[ScalarType] - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -447,8 +455,7 @@ def piecewise_constant(self, durations: List[ScalarType], values: List[ScalarTyp - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -460,6 +467,8 @@ def piecewise_constant(self, durations: List[ScalarType], values: List[ScalarTyp - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -477,10 +486,11 @@ def piecewise_constant(self, durations: List[ScalarType], values: List[ScalarTyp - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -545,8 +555,7 @@ def fn(self, fn: Callable, duration: ScalarType): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address another location(s) - Possible Next : @@ -557,10 +566,12 @@ def fn(self, fn: Callable, duration: ScalarType): :: record the value of waveform at current time -> `.sample()` - :: sample the current callable at given time points. + :: sample current callable at given time points - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -578,10 +589,11 @@ def fn(self, fn: Callable, duration: ScalarType): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -626,8 +638,8 @@ def slice( - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address + another location(s) - Possible Next : @@ -636,6 +648,8 @@ def slice( - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -653,10 +667,11 @@ def slice( - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel + - Possible Next : @@ -692,8 +707,8 @@ def record(self, name: str): - Possible Next : -> `.location(int)` - :: continue building the waveform sequence, - Addressing another location + :: creating new channel to address + another location(s) - Possible Next : @@ -705,6 +720,8 @@ def record(self, name: str): - Possible Next : + :: Append waveform into current channel + -> `.linear()` -> `.constant()` @@ -722,10 +739,10 @@ def record(self, name: str): - Possible Next : -> `.rydberg` - :: Switch to specify rydberg level coupling channel + :: Create/Switch to new rydberg level coupling channel -> `.hyperfine` - :: Switch to specify hyperfine level coupling channel + :: Create/Switch to new hyperfine level coupling channel - Possible Next :