Skip to content

Commit e8199f5

Browse files
authored
Merge branch 'main' into john/add-qbook-to-docs
2 parents b501585 + ef89c4e commit e8199f5

File tree

3 files changed

+1811
-1804
lines changed

3 files changed

+1811
-1804
lines changed

src/bloqade/analog/factory.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from beartype import beartype
44
from beartype.typing import TYPE_CHECKING, Any, Dict, List, Union, Optional
55

6+
from bloqade.analog.ir.scalar import Variable
67
from bloqade.analog.builder.typing import ScalarType
8+
from bloqade.analog.builder.pragmas import Assignable
79
from bloqade.analog.ir.routine.base import Routine
810
from bloqade.analog.ir.control.waveform import Linear, Constant, Waveform
911

@@ -92,12 +94,12 @@ def piecewise_linear(durations: List[ScalarType], values: List[ScalarType]) -> W
9294
"The length of values must be one greater than the length of durations"
9395
)
9496

95-
pwl_wf = None
96-
for duration, start, stop in zip(durations, values[:-1], values[1:]):
97-
if pwl_wf is None:
98-
pwl_wf = Linear(start, stop, duration)
99-
else:
100-
pwl_wf = pwl_wf.append(Linear(start, stop, duration))
97+
if len(durations) == 0:
98+
raise ValueError("The durations and values lists must not be empty.")
99+
100+
pwl_wf = Linear(values[0], values[1], durations[0])
101+
for duration, start, stop in zip(durations[1:], values[1:-1], values[2:]):
102+
pwl_wf = pwl_wf.append(Linear(start, stop, duration))
101103

102104
return pwl_wf
103105

@@ -128,12 +130,12 @@ def piecewise_constant(
128130
"The length of values must be the same as the length of durations"
129131
)
130132

131-
pwc_wf = None
132-
for duration, value in zip(durations, values):
133-
if pwc_wf is None:
134-
pwc_wf = Constant(value, duration)
135-
else:
136-
pwc_wf = pwc_wf.append(Constant(value, duration))
133+
if len(durations) == 0:
134+
raise ValueError("The durations and values lists must not be empty.")
135+
136+
pwc_wf = Constant(values[0], durations[0])
137+
for duration, value in zip(durations[1:], values[1:]):
138+
pwc_wf = pwc_wf.append(Constant(value, duration))
137139

138140
return pwc_wf
139141

@@ -146,7 +148,7 @@ def rydberg_h(
146148
phase: Optional[Waveform] = None,
147149
static_params: Dict[str, Any] = {},
148150
batch_params: Union[List[Dict[str, Any]], Dict[str, Any]] = [],
149-
args: List[str] = [],
151+
args: List[str | Variable] = [],
150152
) -> Routine:
151153
"""Create a rydberg program with uniform detuning, amplitude, and phase.
152154
@@ -181,10 +183,15 @@ def rydberg_h(
181183
prog = prog.rydberg.detuning.uniform.apply(detuning)
182184

183185
if amplitude is not None:
184-
prog = prog.amplitude.uniform.apply(amplitude)
186+
prog = prog.rydberg.rabi.amplitude.uniform.apply(amplitude)
185187

186188
if phase is not None:
187-
prog = prog.phase.uniform.apply(phase)
189+
prog = prog.rydberg.rabi.phase.uniform.apply(phase)
190+
191+
if not isinstance(prog, Assignable):
192+
raise ValueError(
193+
"At least one of detuning, amplitude, or phase must be provided."
194+
)
188195

189196
prog = prog.assign(**static_params)
190197

src/bloqade/analog/task/exclusive.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
2-
import abc
3-
import uuid
42
import re
3+
import abc
54
import time
5+
import uuid
6+
from dataclasses import field, dataclass
67

8+
from requests import get, request
79
from beartype.typing import Dict
8-
from dataclasses import dataclass, field
910

11+
from bloqade.analog.serialize import Serializer
1012
from bloqade.analog.task.base import Geometry, CustomRemoteTaskABC
1113
from bloqade.analog.builder.typing import ParamType
1214
from bloqade.analog.submission.ir.parallel import ParallelDecoder
@@ -15,8 +17,6 @@
1517
QuEraTaskStatusCode,
1618
)
1719
from bloqade.analog.submission.ir.task_specification import QuEraTaskSpecification
18-
from requests import request, get
19-
from bloqade.analog.serialize import Serializer
2020

2121

2222
class HTTPHandlerABC:

0 commit comments

Comments
 (0)