Skip to content

Commit

Permalink
remove mqt, due to some package conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
evmckinney9 committed Oct 6, 2023
1 parent b3b0bc8 commit d72287e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ install_requires =
LovelyPlots
tqdm
# supermarq # don't include this one, I think it has too many conflicting dependencies
mqt.bench==1.0.3
# mqt.bench==1.0.3

[options.extras_require]
dev =
Expand Down
33 changes: 24 additions & 9 deletions src/transpile_benchy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from typing import List

from transpile_benchy.interfaces.abc_interface import SubmoduleInterface
from transpile_benchy.interfaces.mqt_interface import MQTBench

# from transpile_benchy.interfaces.mqt_interface import MQTBench
from transpile_benchy.interfaces.qasm_interface import (
BQSKitInterface,
QASMBench,
Expand All @@ -16,7 +17,9 @@ class CircuitLibrary:
"""A class to handle the library of circuits."""

def __init__(
self, circuit_list: List[str], interfaces: List[SubmoduleInterface] = None
self,
circuit_list: List[str],
interfaces: List[SubmoduleInterface] = None,
):
"""Initialize the library."""
if interfaces:
Expand All @@ -25,7 +28,7 @@ def __init__(
self.interfaces = []
self.interfaces.append(QASMBench())
self.interfaces.append(RedQueen())
self.interfaces.append(MQTBench(num_qubits=0))
# self.interfaces.append(MQTBench(num_qubits=0))
self.interfaces.append(BQSKitInterface())
self.interfaces.append(QiskitCircuitInterface(num_qubits=0))

Expand All @@ -34,8 +37,12 @@ def __init__(

# verify that all circuits are in the library
for circuit_name in self.circuit_list:
if not any(circuit_name in interface for interface in self.interfaces):
raise ValueError(f"Circuit '{circuit_name}' not found in any interface")
if not any(
circuit_name in interface for interface in self.interfaces
):
raise ValueError(
f"Circuit '{circuit_name}' not found in any interface"
)

def circuit_count(self) -> int:
"""Return the number of circuits in the library."""
Expand Down Expand Up @@ -77,17 +84,25 @@ def get_circuit(self, circuit_name):
base_name, num_qubits = circuit_name.rsplit("_", 1)
if num_qubits.startswith("n"):
num_qubits = num_qubits[1:]
circuit_name = f"{base_name}_n{num_qubits}" # enforce qasm name convention
circuit_name = (
f"{base_name}_n{num_qubits}" # enforce qasm name convention
)
num_qubits = int(num_qubits)

for interface in self.interfaces:
if circuit_name in interface:
if interface.dynamic:
print(f"Loading {circuit_name} from {interface.__class__.__name__}")
print(
f"Loading {circuit_name} from {interface.__class__.__name__}"
)
return interface._load_circuit(base_name, num_qubits)
else:
print(f"Loading {circuit_name} from {interface.__class__.__name__}")
print(
f"Loading {circuit_name} from {interface.__class__.__name__}"
)
return interface._load_circuit(circuit_name)
else:
pass # don't use continue, since this is subroutine of generator
raise ValueError(f"Circuit '{circuit_name}' not found in any interface")
raise ValueError(
f"Circuit '{circuit_name}' not found in any interface"
)

0 comments on commit d72287e

Please sign in to comment.