10
10
from bqskit .compiler import compile
11
11
from bqskit .compiler .machine import MachineModel
12
12
from bqskit .compiler .registry import _workflow_registry
13
- from bqskit .compiler .registry import clear_registry
14
13
from bqskit .compiler .registry import register_workflow
15
14
from bqskit .compiler .workflow import Workflow
16
15
from bqskit .compiler .workflow import WorkflowLike
@@ -74,26 +73,30 @@ class TestRegisterWorkflow:
74
73
75
74
@pytest .fixture (autouse = True )
76
75
def setup (self ) -> None :
77
- # _workflow_registry.clear()
78
- clear_registry ()
76
+ assert _workflow_registry == _workflow_registry
77
+ global _workflow_registry
78
+ _workflow_registry .clear ()
79
79
80
80
def test_register_workflow (self ) -> None :
81
+ global _workflow_registry
81
82
assert _workflow_registry == {}
82
83
gateset = [CZGate (), HGate (), RZGate ()]
83
84
num_qudits = 3
84
85
machine = MachineModel (num_qudits , gate_set = gateset )
85
86
workflow = [QuickPartitioner (), ScanningGateRemovalPass ()]
86
- register_workflow (machine , workflow )
87
+ register_workflow (machine , workflow , 1 )
87
88
assert machine in _workflow_registry
88
89
assert 1 in _workflow_registry [machine ]
89
90
assert workflow_match (_workflow_registry [machine ][1 ], workflow )
90
91
91
92
def test_custom_compile_machine (self ) -> None :
93
+ global _workflow_registry
94
+ assert _workflow_registry == {}
92
95
gateset = [CZGate (), HGate (), RZGate ()]
93
96
num_qudits = 3
94
97
machine = MachineModel (num_qudits , gate_set = gateset )
95
98
workflow = [QuickPartitioner (2 )]
96
- register_workflow (machine , workflow )
99
+ register_workflow (machine , workflow , 1 )
97
100
circuit = simple_circuit (num_qudits , gateset )
98
101
result = compile (circuit , machine )
99
102
assert unitary_match (result , circuit )
@@ -103,11 +106,13 @@ def test_custom_compile_machine(self) -> None:
103
106
assert result .gate_counts == circuit .gate_counts
104
107
105
108
def test_custom_compile_gateset (self ) -> None :
109
+ global _workflow_registry
110
+ assert _workflow_registry == {}
106
111
gateset = [CZGate (), HGate (), RZGate ()]
107
112
num_qudits = 3
108
113
machine = MachineModel (num_qudits , gate_set = gateset )
109
114
workflow = [QuickPartitioner (2 )]
110
- register_workflow (gateset , workflow )
115
+ register_workflow (gateset , workflow , 1 )
111
116
circuit = simple_circuit (num_qudits , gateset )
112
117
result = compile (circuit , machine )
113
118
assert unitary_match (result , circuit )
@@ -117,6 +122,8 @@ def test_custom_compile_gateset(self) -> None:
117
122
assert result .gate_counts == circuit .gate_counts
118
123
119
124
def test_custom_opt_level (self ) -> None :
125
+ global _workflow_registry
126
+ assert _workflow_registry == {}
120
127
gateset = [CZGate (), HGate (), RZGate ()]
121
128
num_qudits = 3
122
129
machine = MachineModel (num_qudits , gate_set = gateset )
0 commit comments