Skip to content

Commit

Permalink
🚨 fix new ruff warnings
Browse files Browse the repository at this point in the history
Signed-off-by: burgholzer <burgholzer@me.com>
  • Loading branch information
burgholzer committed Nov 9, 2023
1 parent af7ce16 commit 1af720c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
class CDAStyle(UnsrtStyle):
"""Custom style for including PDF links."""

def format_url(self, _e: Entry) -> HRef:
def format_url(self, _e: Entry) -> HRef: # noqa: PLR6301
"""Format URL field as a link to the PDF."""
url = field("url", raw=True)
return href()[url, "[PDF]"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ extend-select = [
"SIM", # flake8-simplify
"T20", # flake8-print
"TCH", # flake8-type-checking
"TID251", # flake8-tidy-imports.banned-api
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"YTT", # flake8-2020
Expand Down
1 change: 0 additions & 1 deletion src/mqt/qcec/compilation_flow_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,3 @@ def generate_profile(
filename = generate_profile_name(optimization_level=optimization_level, mode=mode)
filepath = filepath.joinpath(filename)
write_profile_data_to_file(profile, filepath)
print(f"Wrote profile data to {filepath}")
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 @@ -21,13 +21,13 @@


@pytest.fixture(params=[0, 1, 2, 3])
def optimization_level(request: Any) -> int: # noqa: ANN401
def optimization_level(request: Any) -> int:
"""Fixture for optimization levels."""
return cast(int, request.param)


@pytest.fixture(params=[qcec.AncillaMode.NO_ANCILLA, qcec.AncillaMode.RECURSION, qcec.AncillaMode.V_CHAIN])
def ancilla_mode(request: Any) -> qcec.AncillaMode: # noqa: ANN401
def ancilla_mode(request: Any) -> qcec.AncillaMode:
"""Fixture for ancilla modes."""
return cast(qcec.AncillaMode, request.param)

Expand Down
16 changes: 8 additions & 8 deletions test/python/test_symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ def test_verify_compilation_on_optimization_levels(original_circuit: QuantumCirc
"""Test the verification of the compilation of a circuit to the 5-qubit IBMQ Athens architecture with various optimization levels."""
compiled_circuit = transpile(original_circuit, backend=FakeAthens(), optimization_level=optimization_level)
result = qcec.verify_compilation(original_circuit, compiled_circuit, optimization_level, timeout=3600)
assert (
result.equivalence == qcec.EquivalenceCriterion.equivalent
or result.equivalence == qcec.EquivalenceCriterion.equivalent_up_to_global_phase
)
assert result.equivalence in {
qcec.EquivalenceCriterion.equivalent,
qcec.EquivalenceCriterion.equivalent_up_to_global_phase,
}


@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
Expand All @@ -205,10 +205,10 @@ def test_verify_compilation_on_optimization_levels_config(
result = qcec.verify_compilation(
original_circuit, compiled_circuit, optimization_level, AncillaMode.NO_ANCILLA, config
)
assert (
result.equivalence == qcec.EquivalenceCriterion.equivalent
or result.equivalence == qcec.EquivalenceCriterion.equivalent_up_to_global_phase
)
assert result.equivalence in {
qcec.EquivalenceCriterion.equivalent,
qcec.EquivalenceCriterion.equivalent_up_to_global_phase,
}


def test_performed_instantiations(rz_commute_lhs: QuantumCircuit, rz_commute_rhs_incorrect: QuantumCircuit) -> None:
Expand Down
8 changes: 4 additions & 4 deletions test/python/test_verify_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def test_verify_compilation_on_optimization_levels(original_circuit: QuantumCirc
"""Test the verification of the compilation of a circuit to the 5-qubit IBMQ Athens architecture with various optimization levels."""
compiled_circuit = transpile(original_circuit, backend=FakeAthens(), optimization_level=optimization_level)
result = qcec.verify_compilation(original_circuit, compiled_circuit, optimization_level=optimization_level)
assert (
result.equivalence == qcec.EquivalenceCriterion.equivalent
or result.equivalence == qcec.EquivalenceCriterion.equivalent_up_to_global_phase
)
assert result.equivalence in {
qcec.EquivalenceCriterion.equivalent,
qcec.EquivalenceCriterion.equivalent_up_to_global_phase,
}


def test_warning_on_missing_measurements() -> None:
Expand Down

0 comments on commit 1af720c

Please sign in to comment.