Skip to content

Commit c2ab442

Browse files
committed
Refactor: Remove unused import and add reset method to Emit classes
1 parent c6573cd commit c2ab442

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .squin2native import (
22
GateRule as GateRule,
33
SquinToNative as SquinToNative,
4-
SquinToNativePass as SquinToNativePass,
54
)

src/bloqade/qasm2/emit/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ def assert_node(
8282
if not isinstance(node, typ):
8383
raise TypeError(f"expected {typ}, got {type(node)}")
8484
return node
85+
86+
def reset(self):
87+
pass

src/bloqade/stim/emit/stim_str.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def get_attribute(self, frame: EmitStimFrame, node: ir.Attribute) -> str:
4848
raise ValueError(f"Method not found for node: {node}")
4949
return method(self, frame, node)
5050

51+
def reset(self):
52+
self.io.truncate(0)
53+
self.io.seek(0)
54+
5155

5256
@func.dialect.register(key="emit.stim")
5357
class FuncEmit(interp.MethodTable):

test/stim/dialects/stim/test_stim_circuits.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def test_controlled_two_qubit_gates():
5858
# print(interp.get_output())
5959

6060

61+
test_gates()
62+
63+
6164
def test_noise():
6265
@stim.main
6366
def test_depolarize():

test/stim/passes/test_squin_debug_to_stim.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import io
12
import os
23

34
from kirin import ir
45
from kirin.dialects import py, debug
56

7+
from bloqade import stim
68
from bloqade.squin import kernel
79
from bloqade.stim.emit import EmitStimMain
810
from bloqade.stim.passes import SquinToStimPass
@@ -11,10 +13,11 @@
1113
# Taken gratuitously from Kai's unit test
1214
def codegen(mt: ir.Method):
1315
# method should not have any arguments!
14-
emit = EmitStimMain()
16+
buf = io.StringIO()
17+
emit = EmitStimMain(dialects=stim.main, io=buf)
1518
emit.initialize()
16-
emit.run(mt=mt, args=())
17-
return emit.get_output()
19+
emit.run(mt)
20+
return buf.getvalue().strip()
1821

1922

2023
def as_int(value: int):

0 commit comments

Comments
 (0)