Skip to content

Commit

Permalink
Merge branch 'main' into zx-two-qubit-rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
burgholzer authored Nov 9, 2023
2 parents b7bab33 + 3bca1f3 commit eb9388d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 33 deletions.
18 changes: 7 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,22 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Run ruff (subsumes pyupgrade, isort, flake8+plugins, and more)
# Python linting and formatting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
rev: v0.1.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

# Run code formatting with Black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0 # Keep in sync with blacken-docs
hooks:
- id: black-jupyter
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]

# Also run Black on examples in the documentation
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.10.0 # keep in sync with black hook
additional_dependencies: [black==23.*]

# CMake format and lint the CMakeLists.txt files
- repo: https://github.com/cheshirekow/cmake-format-precommit
Expand All @@ -81,7 +77,7 @@ repos:

# Clang-format the C++ part of the code base automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.3
rev: v17.0.4
hooks:
- id: clang-format
types_or: [c++, c, cuda]
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration file."""

from __future__ import annotations

import warnings
Expand Down
22 changes: 10 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ filterwarnings = [
'ignore:.*qiskit.__qiskit_version__.*:DeprecationWarning:qiskit:',
'ignore:.*qiskit.utils.algorithm_globals.QiskitAlgorithmGlobals*:DeprecationWarning:qiskit',
'ignore:.*Building a flow controller with keyword arguments is going to be deprecated*:PendingDeprecationWarning:qiskit',
'ignore:.*encountered in det.*:RuntimeWarning:numpy.linalg:',
]

[tool.coverage]
Expand All @@ -151,9 +152,6 @@ report.exclude_also = [
'if TYPE_CHECKING:',
]

[tool.black]
line-length = 120


[tool.mypy]
files = ["src/mqt", "test/python"]
Expand All @@ -171,9 +169,14 @@ module = ["qiskit.*"]
ignore_missing_imports = true

[tool.ruff]
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
select = [
"E", "F", "W", # flake8
line-length = 120
extend-include = ["*.ipynb"]
src = ["src"]
preview = true
unsafe-fixes = true

[tool.ruff.lint]
extend-select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
Expand Down Expand Up @@ -212,16 +215,11 @@ select = [
]
extend-ignore = [
"ANN101", # Missing type annotation for self in method
"ANN102", # Missing type annotation for cls in classmethod
"E501", # Line too long (Black is enough)
"PLR", # Design related pylint codes
]
src = ["src"]
flake8-unused-arguments.ignore-variadic-names = true
isort.required-imports = ["from __future__ import annotations"]
line-length = 120

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"*.pyi" = ["D"] # pydocstyle
"*.ipynb" = [
"D", # pydocstyle
Expand Down
1 change: 1 addition & 0 deletions src/mqt/qcec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This file is part of the MQT QCEC library released under the MIT license.
See README.md or go to https://github.com/cda-tum/qcec for more information.
"""

from __future__ import annotations

from ._version import version as __version__
Expand Down
1 change: 1 addition & 0 deletions src/mqt/qcec/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Types for the QCEC module."""

from __future__ import annotations

from typing import Literal
Expand Down
3 changes: 1 addition & 2 deletions src/mqt/qcec/verify_compilation_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from importlib import resources

from qiskit import QuantumCircuit
from qiskit.transpiler.passes import ContainsInstruction

from . import ApplicationScheme, Configuration, EquivalenceCheckingManager
from .compilation_flow_profiles import AncillaMode, generate_profile_name
Expand All @@ -30,8 +31,6 @@ def __check_if_circuit_contains_measurements(circuit: QuantumCircuit) -> None:
Args:
circuit: The circuit to check.
"""
from qiskit.transpiler.passes import ContainsInstruction

analysis_pass = ContainsInstruction("measure")
analysis_pass(circuit)
if not analysis_pass.property_set["contains_measure"]:
Expand Down
4 changes: 2 additions & 2 deletions test/python/test_compilation_flow_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
else:
from importlib import resources

import difflib

import pytest

from mqt import qcec
Expand Down Expand Up @@ -61,8 +63,6 @@ def test_generated_profiles_are_still_valid(optimization_level: int, ancilla_mod
if equal:
return

import difflib

ref_profile = path.read_text().splitlines(keepends=True)
gen_profile = Path(profile_name).read_text().splitlines(keepends=True)
diff = difflib.unified_diff(ref_profile, gen_profile, fromfile="reference", tofile="generated", n=0)
Expand Down
4 changes: 2 additions & 2 deletions test/python/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from pathlib import Path

import pytest
from qiskit import QuantumCircuit

Expand Down Expand Up @@ -29,8 +31,6 @@ def test_constructor_with_configuration(example_circuit: QuantumCircuit) -> None

def test_default_constructor_with_file(example_circuit: QuantumCircuit) -> None:
"""Test constructing an instance from two circuit files with all default arguments."""
from pathlib import Path

filename = "test.qasm"
example_circuit.qasm(filename=filename)
qcec.EquivalenceCheckingManager(circ1=filename, circ2=filename)
Expand Down
6 changes: 2 additions & 4 deletions test/python/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import annotations

import pytest
from qiskit import QuantumCircuit
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAthens

from mqt import qcec

Expand Down Expand Up @@ -67,9 +68,6 @@ def test_compiled_circuit_without_measurements() -> None:
It makes sure that circuits compiled without measurements are handled correctly.
"""
from qiskit import transpile
from qiskit.providers.fake_provider import FakeAthens

qc = QuantumCircuit(1)
qc.x(0)
qc_compiled = transpile(qc, backend=FakeAthens())
Expand Down

0 comments on commit eb9388d

Please sign in to comment.