Skip to content

Commit

Permalink
Manual Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jesus-talavera-ibm committed Dec 4, 2024
1 parent 93d29d8 commit 400c0eb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
5 changes: 2 additions & 3 deletions qiskit_ibm_transpiler/ai/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from qiskit.circuit.barrier import Barrier
from qiskit.circuit.library import LinearFunction, PermutationGate
from qiskit.converters import circuit_to_dag, dag_to_dagdependency, dagdependency_to_dag
from qiskit.dagcircuit.collect_blocks import BlockCollector
from qiskit.dagcircuit.dagcircuit import DAGCircuit
from qiskit.quantum_info.operators import Clifford
from qiskit.transpiler.basepasses import TransformationPass
Expand Down Expand Up @@ -104,8 +105,6 @@ def run(self, dag: DAGCircuit):
_flatten_permutations = Flatten(("permutation", "Permutation"))
_flatten_paulinetworks = Flatten(("paulinetwork", "PauliNetwork"))

from qiskit.dagcircuit.collect_blocks import BlockCollector


class GreedyBlockCollector(BlockCollector):
def __init__(self, dag, max_block_size):
Expand Down Expand Up @@ -212,7 +211,7 @@ def __init__(
collect_from_back=False,
num_reps=10,
):
collect_function = lambda dag: GreedyBlockCollector(
collect_function = lambda dag: GreedyBlockCollector( # noqa:E731
dag, max_block_size
).collect_all_matching_blocks(
filter_fn=block_checker.select,
Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_transpiler/ai/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def __init__(
local_mode: bool = False,
**kwargs,
) -> None:
if local_mode == True:
if local_mode == True: # noqa:E712
raise Exception(
"Pauli Network is not available locally, only in the Qiskit Transpiler Service"
)
Expand Down
4 changes: 2 additions & 2 deletions qiskit_ibm_transpiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def random_permutation(n_qubits):


def create_random_linear_function(n_qubits: int, seed: int = 123) -> LinearFunction:
rand_lin = lambda seed: LinearFunction(
rand_lin = lambda seed: LinearFunction( # noqa:E731
random_invertible_binary_matrix(n_qubits, seed=seed)
)

Expand All @@ -71,7 +71,7 @@ def create_random_linear_function(n_qubits: int, seed: int = 123) -> LinearFunct
def random_clifford_from_linear_function(n_qubits: int, seed: int = 123):
"""Generate a random clifford from a random linear function of n_qubits qubits."""

random_linear = lambda seed: LinearFunction(
random_linear = lambda seed: LinearFunction( # noqa:E731
random_invertible_binary_matrix(n_qubits, seed=seed)
)
random_clifford = Clifford(random_linear(seed))
Expand Down
22 changes: 10 additions & 12 deletions qiskit_ibm_transpiler/wrappers/ai_local_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@

import importlib
import logging
from typing import List, Union

import networkx as nx
import numpy as np
from networkx.exception import NetworkXError
from qiskit import QuantumCircuit
from qiskit.circuit.library import LinearFunction
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.quantum_info import Clifford
from qiskit.transpiler import CouplingMap

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

ai_local_package = "qiskit_ibm_ai_local_transpiler"
qiskit_ibm_ai_local_transpiler = (
Expand Down Expand Up @@ -71,18 +81,6 @@
"CLIFFORD_COUPLING_MAPS_BY_HASHES_DICT not found",
)

from typing import List, Union

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.library import LinearFunction
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.quantum_info import Clifford
from qiskit.transpiler import CouplingMap

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


def validate_coupling_map_source(coupling_map, backend):
if not coupling_map and not backend:
Expand Down
2 changes: 1 addition & 1 deletion qiskit_transpiler_service/transpiler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

import logging
from typing import Dict, List, Literal, Union
from warnings import warn

from qiskit_ibm_transpiler import TranspilerService as NewTranspilerService

logger = logging.getLogger(__name__)
from warnings import warn


class TranspilerService(NewTranspilerService):
Expand Down
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

select = ["E", "I"]

ignore = ["E501"]

# Ignore `F401` (unused import violations) in all `__init__.py` files.
[lint.per-file-ignores]
"__init__.py" = ["F401"]

0 comments on commit 400c0eb

Please sign in to comment.