Skip to content

Commit

Permalink
merging definitions of add_positions and add_positions (#591)
Browse files Browse the repository at this point in the history
* adding dispatch of `add_position` to list as well as numpy array.

* bump minor version.

* fixing readme.

* Update philosophy.md

* adding back beartype checks

* removing `singledispatchmethod` because it create a property not a method.

* updating docs.

* adding test for assertion error.
  • Loading branch information
weinbe58 authored Sep 17, 2023
1 parent 11c647b commit c3718da
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 60 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ calculation = (
```

From here there will be different methods and properties that you can use to build your program. For example,
you can start to add atom sites to your program by selecting `add_position` method or `add_positions` method.
you can start to add atom sites to your program by selecting `add_position`.

```python
from bloqade import start
Expand All @@ -45,7 +45,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
)
```

Expand All @@ -58,7 +58,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg
)
```
Expand All @@ -73,7 +73,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning
)
```
Expand All @@ -88,7 +88,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform
)
```
Expand All @@ -103,7 +103,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand All @@ -121,7 +121,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand Down Expand Up @@ -149,7 +149,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand All @@ -176,7 +176,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand Down Expand Up @@ -208,7 +208,7 @@ program = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand Down
20 changes: 10 additions & 10 deletions docs/docs/getting_started/philosophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ calculation = (
```

From here there will be different methods and properties that you can use to build your program. For example,
you can start to add atom sites to your program by selecting `add_position` method or `add_positions` method.
you can start to add atom sites to your program by selecting `add_position` method.

```python
from bloqade import start
Expand All @@ -19,7 +19,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
)
```

Expand All @@ -32,7 +32,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg
)
```
Expand All @@ -47,7 +47,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning
)
```
Expand All @@ -62,7 +62,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform
)
```
Expand All @@ -77,7 +77,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0 0.1],
Expand All @@ -95,7 +95,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0 0.1],
Expand Down Expand Up @@ -123,7 +123,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0 0.1],
Expand All @@ -150,7 +150,7 @@ calculation = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0 0.1],
Expand Down Expand Up @@ -182,7 +182,7 @@ program = (
start
.add_position((0, 0))
.add_position((0, 6.8))
.add_positions([(6.8, 0), (6.8, 6.8)])
.add_position([(6.8, 0), (6.8, 6.8)])
.rydberg.detuning.uniform.
piecewise_linear(
durations = [0.1, 1.0, 0.1],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bloqade"
version = "0.3.7"
version = "0.4.7"
description = "Neutral atom software development kit"
authors = [
{name = "QuEra Computing Inc.", email = "info@quera.com"},
Expand Down
8 changes: 4 additions & 4 deletions src/bloqade/builder/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def uniform(self):
- Addressing rydberg detuning to all atoms in the system with
4 sites
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.uniform
"""
Expand All @@ -59,13 +59,13 @@ def location(self, label: int):
- 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)])
>>> reg = bloqade.start.add_position([(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)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.location(1).location(2)
Note:
Expand Down Expand Up @@ -142,7 +142,7 @@ def var(self, name: str):
- Addressing rydberg detuning to atom location `myatom` in the system with
4 sites
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.var('myatom')
"""
Expand Down
4 changes: 2 additions & 2 deletions src/bloqade/builder/pragmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def assign(self, **assignments) -> "Assign":
and 0.5 to the variable "span_time".
>>> reg = bloqade.start
... .add_positions([(0,0),(1,1),(2,2),(3,3)])
... .add_position([(0,0),(1,1),(2,2),(3,3)])
>>> seq = reg.rydberg.detuning.uniform
... .linear(start="ival",stop=1,duration="span_time")
>>> seq = seq.assign(span_time = 0.5, ival = 0.0)
Expand Down Expand Up @@ -65,7 +65,7 @@ def parallelize(self, cluster_spacing: ScalarType) -> Parallelize:
- Parallelize the current problem with cluster spacing 7.2 um.
>>> prob = (
bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
.rydberg.detuning.uniform
.linear(start=0,stop=1,duration=1)
)
Expand Down
16 changes: 8 additions & 8 deletions src/bloqade/builder/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class Uniform(SpatialModulation):
- To hit this node from the start node:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.uniform
- Apply Linear waveform:
>>> wv = bloqade.ir.Linear(start=0,stop=1,duration=0.5)
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.uniform.apply(wv)
"""
Expand Down Expand Up @@ -61,13 +61,13 @@ def location(self, label: int) -> "Location":
- Append location 1 to the current location 0.
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(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)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.location(0)
>>> loc = loc.location(1).location(2)
Expand Down Expand Up @@ -120,19 +120,19 @@ def scale(self, value: ScalarType) -> "Scale":
- Scale the preceeding waveform that addressing location(0) by 1.2.
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> scaled = reg.rydberg.detuning.location(0).scale(1.2)
- Scale multiple locations with different factors.
(ex. loc 0 by 1.2, loc 1 by 0.5)
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.location(0)
>>> loc = loc.scale(1.2).location(1).scale(0.5)
- Scale multiple locations with the same factor. (ex. loc 0 and 1 by 1.2)
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> scaled = reg.rydberg.detuning.location(0).location(1).scale(1.2)
Expand Down Expand Up @@ -192,7 +192,7 @@ def location(self, label: int) -> "Location":
- Append location 1 after scale location 0 by 1.2.
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
>>> reg = bloqade.start.add_position([(0,0),(1,1),(2,2),(3,3)])
>>> loc = reg.rydberg.detuning.location(0).scale(1.2)
>>> loc = loc.location(1)
Expand Down
Loading

0 comments on commit c3718da

Please sign in to comment.