Skip to content

Commit

Permalink
Removed clear_registry function
Browse files Browse the repository at this point in the history
  • Loading branch information
mtweiden committed Aug 28, 2024
1 parent b6219a9 commit 6e31654
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/compiler/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from bqskit.compiler import compile
from bqskit.compiler.machine import MachineModel
from bqskit.compiler.registry import _workflow_registry
from bqskit.compiler.registry import clear_registry
from bqskit.compiler.registry import register_workflow
from bqskit.compiler.workflow import Workflow
from bqskit.compiler.workflow import WorkflowLike
Expand Down Expand Up @@ -74,26 +73,30 @@ class TestRegisterWorkflow:

@pytest.fixture(autouse=True)
def setup(self) -> None:
# _workflow_registry.clear()
clear_registry()
assert _workflow_registry == _workflow_registry
global _workflow_registry
_workflow_registry.clear()

def test_register_workflow(self) -> None:
global _workflow_registry
assert _workflow_registry == {}
gateset = [CZGate(), HGate(), RZGate()]
num_qudits = 3
machine = MachineModel(num_qudits, gate_set=gateset)
workflow = [QuickPartitioner(), ScanningGateRemovalPass()]
register_workflow(machine, workflow)
register_workflow(machine, workflow, 1)
assert machine in _workflow_registry
assert 1 in _workflow_registry[machine]
assert workflow_match(_workflow_registry[machine][1], workflow)

def test_custom_compile_machine(self) -> None:
global _workflow_registry
assert _workflow_registry == {}
gateset = [CZGate(), HGate(), RZGate()]
num_qudits = 3
machine = MachineModel(num_qudits, gate_set=gateset)
workflow = [QuickPartitioner(2)]
register_workflow(machine, workflow)
register_workflow(machine, workflow, 1)
circuit = simple_circuit(num_qudits, gateset)
result = compile(circuit, machine)
assert unitary_match(result, circuit)
Expand All @@ -103,11 +106,13 @@ def test_custom_compile_machine(self) -> None:
assert result.gate_counts == circuit.gate_counts

def test_custom_compile_gateset(self) -> None:
global _workflow_registry
assert _workflow_registry == {}
gateset = [CZGate(), HGate(), RZGate()]
num_qudits = 3
machine = MachineModel(num_qudits, gate_set=gateset)
workflow = [QuickPartitioner(2)]
register_workflow(gateset, workflow)
register_workflow(gateset, workflow, 1)
circuit = simple_circuit(num_qudits, gateset)
result = compile(circuit, machine)
assert unitary_match(result, circuit)
Expand All @@ -117,6 +122,8 @@ def test_custom_compile_gateset(self) -> None:
assert result.gate_counts == circuit.gate_counts

def test_custom_opt_level(self) -> None:
global _workflow_registry
assert _workflow_registry == {}
gateset = [CZGate(), HGate(), RZGate()]
num_qudits = 3
machine = MachineModel(num_qudits, gate_set=gateset)
Expand Down

0 comments on commit 6e31654

Please sign in to comment.