Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix improper printing on ScaledLocations #361

Merged
merged 62 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
be47097
add more tests
Jul 14, 2023
a87ab8a
Merge branch 'main' into khwu/enhance_testv4
Jul 14, 2023
a0c9d64
add more integration tests for codegen
Jul 14, 2023
0ca26b3
fix bug when ConstantCodeGen hit Negative wvfm node.
Jul 17, 2023
0e906a1
Merge branch 'main' into khwu/enhance_testv4
Jul 17, 2023
69d9ce1
tmp
Jul 17, 2023
6d0c109
fix bug when slice produce duplicate time points
Jul 17, 2023
a8fccb7
Merge branch 'khwu/enhance_testv4' into khwu/enhance_testv5
Jul 17, 2023
fea7e20
tmp
Jul 17, 2023
4a1627e
Merge branch 'main' into khwu/enhance_testv5
Jul 17, 2023
698e834
tmp
Jul 17, 2023
c92ef69
Merge branch 'main' into khwu/enhance_testv5
Jul 17, 2023
af7c0da
adding fix for Sample interpolation.
weinbe58 Jul 17, 2023
af59e4c
tmp
Jul 17, 2023
9bfe755
Merge branch 'phil/fix-sample-waveform-ast' into khwu/enhance_testv5
Jul 17, 2023
61bf678
add framework for pretty print testing and fix bugs #297
Jul 17, 2023
2c725e7
fix bug in print with children
Jul 17, 2023
dfc4fc8
remove [html] from .coveragerc and fix bugs in print testing
Jul 17, 2023
48c181e
finished assignment scan tests
Jul 17, 2023
bf58a4d
fix bug in codegen slice
Jul 18, 2023
72e0fdb
fix conflict
Jul 18, 2023
0348945
making `Append` give correct value for `eval_decimal(duration)`.
weinbe58 Jul 18, 2023
5e8d290
add more tests for batch_assign
Jul 18, 2023
c0c15ba
Merge branch '302-record-does-not-properly-record-the-current-value' …
Jul 18, 2023
cc36d42
add more testing cases
Jul 18, 2023
4fa82cd
Merge branch 'main' into khwu/enhance_testv6
Jul 18, 2023
0263bd1
add more tests and fix bugs related to fn() sampling
Jul 18, 2023
e967816
Merge branch 'main' into khwu/enhance_testv8
Jul 18, 2023
68db7b2
Merge branch 'main' into khwu/enhance_testv8
weinbe58 Jul 19, 2023
b01c23d
fixing `samples` of `Sample` + adding example of using codegen directly.
weinbe58 Jul 19, 2023
80013b8
fix bug in matching of namedpulese
Jul 20, 2023
4c0339f
finalize
Jul 20, 2023
652ac0b
fix docstrings cannot properly display and parsing issue
Jul 20, 2023
e9ad48e
tempo update
Jul 21, 2023
ef337d0
Merge branch 'main' into khwu/doc_s2
Jul 21, 2023
01563fc
add tree and builder docs
Jul 21, 2023
928dddd
update doc
Jul 24, 2023
2135963
add docs for waveform
Jul 24, 2023
2781dd1
finished documenting builder part, and hiding non-user parts
Jul 24, 2023
728a0c5
update, fix builder linking, and add some doc for task/
Jul 25, 2023
85b89ea
update doc with changes from merging with main
Jul 25, 2023
194a14e
tmp
Jul 25, 2023
7f86585
change node to Compile instead of codegen
Jul 25, 2023
694f1af
hide parts that are internal from users
Jul 25, 2023
8b03c2a
add documentations for ir
Jul 25, 2023
749cb07
add more docstrings
Jul 25, 2023
c8f6f72
start adding prompt for IDE
Jul 25, 2023
64bafe5
compress the printing layout
Jul 26, 2023
03f570b
tmp
Jul 26, 2023
2cc6a0d
Merge branch 'main' into khwu/compat_print
Jul 26, 2023
1e94c1e
auto detect if terminal support unicode
Jul 26, 2023
a8c9869
make all default printing pretty print. and move old __repr__ to __st…
Jul 27, 2023
2f87a4b
finished pretty printing
Jul 27, 2023
c26afec
mod str
Jul 27, 2023
6752f83
fix conflict
Jul 27, 2023
2163eee
Merge branch 'main' into khwu/compat_print
Jul 31, 2023
a516f51
move all printing to base
Aug 1, 2023
bc4fe10
add files, move all printing to base, and resolve conflict
Aug 1, 2023
299537c
fix MockPrinter instances got instantiate upon import
Aug 1, 2023
29b46f5
fix bug in ScaledLocations not properly printed
Aug 2, 2023
288a81f
merge
Aug 2, 2023
87eedeb
fix testing cases
Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bloqade/ir/control/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def __str__(self):
return f"ScaledLocations(value={str(self.value)})"

def print_node(self):
return "ScaledLocations"
## formatting location: scale pair:
tmp = {f"{key.value}": val for key, val in self.value.items()}
return f"ScaledLocations({str(tmp)})"

def children(self):
# can return list or dict
Expand Down
7 changes: 5 additions & 2 deletions src/bloqade/ir/tree_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ def get_value(self):


class Printer:
def __init__(self, p=MockPrinter()):
def __init__(self, p=None):
self.charset = UnicodeCharSet() if unicode_enabled else ASCIICharSet()
self.state = State()
self.p = p
if p is None:
self.p = MockPrinter()
else:
self.p = p
self.max_tree_depth = max_tree_depth

def should_print_annotation(self, children):
Expand Down
10 changes: 6 additions & 4 deletions tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_scal_loc():
with pytest.raises(ValueError):
ScaledLocations({(2, 3): 2})

assert x.print_node() == "ScaledLocations"
assert x.print_node() == "ScaledLocations({'1': 1.0, '2': 2.0})"
assert x.children() == {"Location 1": cast(1.0), "Location 2": cast(2.0)}

mystdout = StringIO()
Expand All @@ -74,7 +74,7 @@ def test_scal_loc():

assert (
mystdout.getvalue()
== "ScaledLocations\n"
== "ScaledLocations({'1': 1.0, '2': 2.0})\n"
+ "├─ Location 1\n"
+ "│ ⇒ Literal: 1.0\n"
+ "⋮\n"
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_field():
assert (
mystdout.getvalue()
== "Field\n"
+ "└─ ScaledLocations\n"
+ "└─ ScaledLocations({'1': 1.0, '2': 2.0})\n"
+ " ⇒ Linear\n"
+ " ├─ start\n"
+ " │ ⇒ Literal: 1.0\n"
Expand All @@ -123,5 +123,7 @@ def test_field():
assert f2.print_node() == "Field"
# assert type(hash(f1)) == int
assert f1.children() == {
"ScaledLocations": Linear(start=1.0, stop=cast("x"), duration=3.0)
"ScaledLocations({'1': 1.0, '2': 2.0})": Linear(
start=1.0, stop=cast("x"), duration=3.0
)
}
Loading