-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs on bravais, add more tests, and bump up coverages (#285)
* add more tests and enhance cast 1) add tests for scales 2) add tests for bravais 3) to do 2) this commit add cast for tuple type * tmp * add more testing cases, bumping to 71% * fix baravias bugs and more test 1) fix bugs on wrong index*elementary vectors 2) bump testing cases on bravias to 96 3) fix bugs on Rectangular when spacing_y dose not specify * update to comply ruff * modify to comply ruff * modify to comply black * modify format * try * test pre-compile * pre-commit linter fix --------- Co-authored-by: Kai-Hsin Wu <khwu@KHWus-MBP.hsd1.ma.comcast.net> Co-authored-by: Kai-Hsin Wu <khwu@KHWus-MacBook-Pro.local>
- Loading branch information
1 parent
4b21826
commit 6514f67
Showing
5 changed files
with
238 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from bloqade.builder.factory import ( | ||
piecewise_linear, | ||
piecewise_constant, | ||
constant, | ||
linear, | ||
) | ||
from bloqade import cast | ||
|
||
|
||
def test_ir_piecewise_linear(): | ||
A = piecewise_linear([0.1, 3.8, 0.2], [-10, -7, "a", "b"]) | ||
|
||
## Append type ir node | ||
assert len(A.waveforms) == 3 | ||
assert A.waveforms[0].duration == cast(0.1) | ||
assert A.waveforms[0].start == cast(-10) | ||
assert A.waveforms[0].stop == cast(-7) | ||
|
||
assert A.waveforms[1].duration == cast(3.8) | ||
assert A.waveforms[1].start == cast(-7) | ||
assert A.waveforms[1].stop == cast("a") | ||
|
||
assert A.waveforms[2].duration == cast(0.2) | ||
assert A.waveforms[2].start == cast("a") | ||
assert A.waveforms[2].stop == cast("b") | ||
|
||
|
||
def test_ir_const(): | ||
A = constant(value=3.415, duration=0.55) | ||
|
||
## Constant type ir node: | ||
assert A.value == cast(3.415) | ||
assert A.duration == cast(0.55) | ||
|
||
|
||
def test_ir_linear(): | ||
A = linear(start=0.5, stop=3.2, duration=0.76) | ||
|
||
## Linear type ir node: | ||
assert A.start == cast(0.5) | ||
assert A.stop == cast(3.2) | ||
assert A.duration == cast(0.76) | ||
|
||
|
||
def test_ir_piecewise_constant(): | ||
A = piecewise_constant(durations=[0.1, 3.8, 0.2], values=[-10, "a", "b"]) | ||
|
||
assert A.waveforms[0].duration == cast(0.1) | ||
assert A.waveforms[0].value == cast(-10) | ||
|
||
assert A.waveforms[1].duration == cast(3.8) | ||
assert A.waveforms[1].value == cast("a") | ||
|
||
assert A.waveforms[2].duration == cast(0.2) | ||
assert A.waveforms[2].value == cast("b") |