Skip to content

Commit

Permalink
Format: Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss committed May 29, 2024
1 parent d5f635f commit 7a0d267
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions qiskit/transpiler/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
import itertools

from typing import Optional, List, Any
from collections.abc import Mapping
from collections import defaultdict
import datetime
import io
import logging
import inspect

import rustworkx as rx

# import target class from the rust side
from qiskit._accelerate.target import ( # pylint: disable=unused-import
BaseTarget,
BaseInstructionProperties,
)

from qiskit.circuit.parameter import Parameter
from qiskit.circuit.parameterexpression import ParameterValueType
from qiskit.circuit.gate import Gate
Expand All @@ -54,13 +58,6 @@
logger = logging.getLogger(__name__)


# import target class from the rust side
from qiskit._accelerate.target import ( # pylint: disable=unused-import
BaseTarget,
BaseInstructionProperties,
)


class InstructionProperties(BaseInstructionProperties):
"""A representation of the properties of a gate implementation.
Expand All @@ -82,8 +79,8 @@ def __new__( # pylint: disable=keyword-arg-before-vararg

def __init__(
self,
duration: float | None = None,
error: float | None = None,
duration: float | None = None, # pylint: disable=unused-argument
error: float | None = None, # pylint: disable=unused-argument
calibration: Schedule | ScheduleBlock | CalibrationEntry | None = None,
):
"""Create a new ``InstructionProperties`` object
Expand Down Expand Up @@ -239,7 +236,7 @@ class Target(BaseTarget):
would potentially be invalidated by removals.
"""

def __new__(
def __new__( # pylint: disable=keyword-arg-before-vararg
cls,
description: str | None = None,
num_qubits: int = 0,
Expand All @@ -250,7 +247,7 @@ def __new__(
acquire_alignment: int = 1,
qubit_properties: list | None = None,
concurrent_measurements: list | None = None,
*args, # pylint: disable=unused-argument
*args, # pylint: disable=unused-argument disable=keyword-arg-before-vararg
**kwargs, # pylint: disable=unused-argument
):
"""
Expand Down Expand Up @@ -510,7 +507,7 @@ def update_from_instruction_schedule_map(self, inst_map, inst_name_map=None, err
continue
try:
# Update gate error if provided.
props.error = error_dict[inst_name][qargs]
setattr(props, "error", error_dict[inst_name][qargs])
except (KeyError, TypeError):
pass
out_props[qargs] = props
Expand Down Expand Up @@ -565,7 +562,7 @@ def qargs(self):
qargs = super().qargs
if qargs is None:
return None
qargs = set(tuple(qarg) for qarg in qargs)
qargs = {tuple(qarg) for qarg in qargs}
return qargs

def qargs_for_operation_name(self, operation):
Expand Down Expand Up @@ -856,6 +853,7 @@ def __getitem__(self, key):
return self._gate_map[key]

def get(self, key, default=None):
"""Gets an item from the Target. If not found return a provided default or `None`."""
try:
return self[key]
except KeyError:
Expand All @@ -868,12 +866,15 @@ def __contains__(self, item):
return item in self._gate_map

def keys(self):
"""Return the keys (operation_names) of the Target"""
return self._gate_map.keys()

def values(self):
"""Return the Property Map (qargs -> InstructionProperties) of every instruction in the Target"""
return self._gate_map.values()

def items(self):
"""Returns pairs of Gate names and its property map (str, dict[tuple, InstructionProperties])"""
return self._gate_map.items()

def __str__(self):
Expand Down

0 comments on commit 7a0d267

Please sign in to comment.