Skip to content
New issue

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

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

Already on GitHub? # to your account

⬆️🪝 update pre-commit hooks #318

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ repos:
types_or: [yaml, markdown, html, css, javascript, json]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.3.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/devices/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_available_basis_gates(cls) -> list[list[str]]:
@classmethod
def get_max_qubits(cls) -> int:
"""Get the maximum number of qubits offered by a device from the provider."""
return max([device.num_qubits for device in cls.get_available_devices()])
return max(device.num_qubits for device in cls.get_available_devices())

@classmethod
@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/evaluation/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def evaluate_qasm_file(filename: str) -> EvaluationResult | None:


def count_occurrences(filenames: list[str], search_str: str) -> int:
return sum([search_str in filename for filename in filenames])
return sum(search_str in filename for filename in filenames)


def count_qubit_numbers_per_compiler(filenames: list[str], compiler: str) -> list[int]:
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/qiskit_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_indep_level(
if return_qc == True -- quantum circuit object
else -- True/False indicating whether the function call was successful or not
"""
filename_indep = target_filename if target_filename else qc.name + "_indep_qiskit_" + str(num_qubits)
filename_indep = target_filename or qc.name + "_indep_qiskit_" + str(num_qubits)

path = Path(target_directory, filename_indep + ".qasm")
if file_precheck and path.is_file():
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/tket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_indep_level(
if return_qc == True -- quantum circuit object
else -- True/False indicating whether the function call was successful or not
"""
filename_indep = target_filename if target_filename else qc.name + "_indep_tket_" + str(num_qubits)
filename_indep = target_filename or qc.name + "_indep_tket_" + str(num_qubits)

path = Path(target_directory, filename_indep + ".qasm")
if file_precheck and path.is_file():
Expand Down
4 changes: 2 additions & 2 deletions src/mqt/bench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def calc_supermarq_features(
for op in dag.two_qubit_ops():
q1, q2 = op.qargs
graph.add_edge(qc.find_bit(q1).index, qc.find_bit(q2).index)
degree_sum = sum([graph.degree(n) for n in graph.nodes])
degree_sum = sum(graph.degree(n) for n in graph.nodes)
program_communication = degree_sum / (num_qubits * (num_qubits - 1)) if num_qubits > 1 else 0

# Liveness feature = sum of all entries in the liveness matrix / (num_qubits * depth).
Expand All @@ -270,7 +270,7 @@ def calc_supermarq_features(

# Critical depth = # of 2-qubit gates along the critical path / total # of 2-qubit gates.
longest_paths = dag.count_ops_longest_path()
n_ed = sum([longest_paths[name] for name in {op.name for op in dag.two_qubit_ops()} if name in longest_paths])
n_ed = sum(longest_paths[name] for name in {op.name for op in dag.two_qubit_ops()} if name in longest_paths)
n_e = len(dag.two_qubit_ops())
critical_depth = n_ed / n_e if n_e != 0 else 0

Expand Down
Loading