Skip to content

Commit

Permalink
Fix transpiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Randl committed Apr 11, 2024
1 parent d1101c8 commit 5f5961a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions qiskit/transpiler/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def from_qubit_list(qubit_list, *qregs):
out.add_register(qreg)
return out

def compose(self, other: Layout, qubits: List[Qubit]) -> Layout:
def compose(self, other: Layout, qubits: list[Qubit]) -> Layout:
"""Compose this layout with another layout.
If this layout represents a mapping from the P-qubits to the positions of the Q-qubits,
Expand All @@ -387,7 +387,7 @@ def compose(self, other: Layout, qubits: List[Qubit]) -> Layout:
other_v2p = other.get_virtual_bits()
return Layout({virt: other_v2p[qubits[phys]] for virt, phys in self._v2p.items()})

def inverse(self, source_qubits: List[Qubit], target_qubits: List[Qubit]):
def inverse(self, source_qubits: list[Qubit], target_qubits: list[Qubit]):
"""Finds the inverse of this layout.
This is possible when the layout is a bijective mapping, however the input
Expand All @@ -414,7 +414,7 @@ def inverse(self, source_qubits: List[Qubit], target_qubits: List[Qubit]):
}
)

def to_permutation(self, qubits: List[Qubit]):
def to_permutation(self, qubits: list[Qubit]):
"""Creates a permutation corresponding to this layout.
This is possible when the layout is a bijective mapping with the same
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/calibration/rx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(

super().__init__()
self.target = target
self.already_generated = {}
self.already_generated = {} # TODO: unused?
self.requires = [NormalizeRXAngle(self.target)]

def supported(self, node_op: Instruction, qubits: list) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def __init__(self, max_block_size: int = 2):

# the dicts below are keyed by a qubit signifying the root of a
# set in the DSU data structure
self.bit_groups: dict[
Qubit, list[Qubit]
] = {} # current groups of bits stored at top of trees
self.bit_groups: dict[Qubit, list[Qubit]] = (
{}
) # current groups of bits stored at top of trees
self.gate_groups: dict[Qubit, list[Qubit]] = {} # current gate lists for the groups

self.max_block_size = max_block_size # maximum block size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def run(self, dag):

def _error(
self, circuit: euler_one_qubit_decomposer.OneQubitGateSequence | Sequence[DAGOpNode], qubit
):
) -> tuple[float, int]:
"""
Calculate a rough error for a `circuit` that runs on a specific
`qubit` of `target` (`circuit` can either be an OneQubitGateSequence
Expand Down
10 changes: 5 additions & 5 deletions qiskit/transpiler/passes/synthesis/aqc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ class AQCSynthesisPlugin(UnitarySynthesisPlugin):
"""

@property
def max_qubits(self):
def max_qubits(self) -> int:
"""Maximum number of supported qubits is ``14``."""
return 14

@property
def min_qubits(self):
def min_qubits(self) -> int:
"""Minimum number of supported qubits is ``3``."""
return 3

@property
def supports_natural_direction(self):
def supports_natural_direction(self) -> bool:
"""The plugin does not support natural direction,
it assumes bidirectional two qubit gates."""
return False
Expand All @@ -98,13 +98,13 @@ def supported_bases(self):
return None

@property
def supports_basis_gates(self):
def supports_basis_gates(self) -> bool:
"""The plugin does not support basis gates and by default it synthesizes a circuit using
``["rx", "ry", "rz", "cx"]`` gate basis."""
return False

@property
def supports_coupling_map(self):
def supports_coupling_map(self) -> bool:
"""The plugin does not support coupling maps."""
return False

Expand Down
3 changes: 3 additions & 0 deletions qiskit/transpiler/preset_passmanagers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
from __future__ import annotations

import collections
from collections.abc import Sequence
from typing import Optional

from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel
from qiskit.circuit.controlflow import CONTROL_FLOW_OP_NAMES

from qiskit.passmanager.flow_controllers import ConditionalController
from qiskit.transpiler.basepasses import BasePass
from qiskit.transpiler.passmanager import PassManager
from qiskit.transpiler.passes import Error
from qiskit.transpiler.passes import BasisTranslator
Expand Down Expand Up @@ -450,6 +452,7 @@ def generate_translation_passmanager(
Raises:
TranspilerError: If the ``method`` kwarg is not a valid value
"""
unroll: Sequence[BasePass]
if method == "translator":
unroll = [
# Use unitary synthesis for basis aware decomposition of
Expand Down

0 comments on commit 5f5961a

Please sign in to comment.