Skip to content

Commit

Permalink
remove the imports for type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Aug 6, 2024
1 parent efee1ba commit 921ea6c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from qiskit.dagcircuit import DAGCircuit
from qiskit.providers.backend import Backend
from qiskit.providers.backend_compat import BackendV2Converter
from qiskit.providers.models import BackendProperties
from qiskit.pulse import Schedule, InstructionScheduleMap
from qiskit.transpiler import Layout, CouplingMap, PropertySet
from qiskit.transpiler.basepasses import BasePass
Expand All @@ -44,7 +43,7 @@ def transpile( # pylint: disable=too-many-return-statements
basis_gates: Optional[List[str]] = None,
inst_map: Optional[List[InstructionScheduleMap]] = None,
coupling_map: Optional[Union[CouplingMap, List[List[int]]]] = None,
backend_properties: Optional[BackendProperties] = None,
backend_properties=None,
initial_layout: Optional[Union[Layout, Dict, List]] = None,
layout_method: Optional[str] = None,
routing_method: Optional[str] = None,
Expand Down Expand Up @@ -119,7 +118,8 @@ def transpile( # pylint: disable=too-many-return-statements
specifies all directed two-qubit interactions supported by backend,
e.g: ``[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]``
backend_properties: properties returned by a backend, including information on gate
backend_properties (BackendProperties or None): properties returned by a backend,
including information on gate
errors, readout errors, qubit coherence times, etc. Find a backend
that provides this information with: ``backend.properties()``
initial_layout: Initial position of virtual qubits on physical qubits.
Expand Down
11 changes: 1 addition & 10 deletions qiskit/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,20 +779,11 @@ def status(self):
There is also a :class:`~.BackendV2Converter` class available that enables you
to wrap a :class:`~.BackendV1` object with a :class:`~.BackendV2` interface.
"""
import warnings

# Providers interface
from qiskit.providers.provider import Provider
from qiskit.providers.provider import ProviderV1

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r"qiskit\.providers\.models.+",
module="qiskit",
)
from qiskit.providers.backend import Backend
from qiskit.providers.backend import Backend
from qiskit.providers.backend import BackendV1
from qiskit.providers.backend import BackendV2
from qiskit.providers.backend import QubitProperties
Expand Down
27 changes: 19 additions & 8 deletions qiskit/providers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from abc import abstractmethod
import datetime
from typing import List, Union, Iterable, Tuple
import warnings

from qiskit.providers.provider import Provider
from qiskit.providers.models.backendstatus import BackendStatus
from qiskit.circuit.gate import Instruction
from qiskit.utils import deprecate_func

Expand Down Expand Up @@ -172,13 +172,24 @@ def status(self):
Returns:
BackendStatus: the status of the backend.
"""
return BackendStatus(
backend_name=self.name(),
backend_version="1",
operational=True,
pending_jobs=0,
status_msg="",
)
with warnings.catch_warnings():
# BackendV1 is deprecated along qiskit.providers.models.backendstatus.BackendStatus
# They both need to be removed at the same time
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r"qiskit\.providers\.models.+",
module="qiskit",
)
from qiskit.providers.models.backendstatus import BackendStatus

return BackendStatus(
backend_name=self.name(),
backend_version="1",
operational=True,
pending_jobs=0,
status_msg="",
)

def name(self):
"""Return the backend name.
Expand Down
17 changes: 7 additions & 10 deletions qiskit/providers/backend_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@

from qiskit.providers.backend import BackendV1, BackendV2
from qiskit.providers.backend import QubitProperties
from qiskit.providers.models.backendconfiguration import BackendConfiguration
from qiskit.providers.models.backendproperties import BackendProperties
from qiskit.circuit.controlflow import CONTROL_FLOW_OP_NAMES
from qiskit.providers.models.pulsedefaults import PulseDefaults
from qiskit.providers.options import Options
from qiskit.providers.exceptions import BackendPropertyError

logger = logging.getLogger(__name__)


def convert_to_target(
configuration: BackendConfiguration,
properties: BackendProperties = None,
defaults: PulseDefaults = None,
configuration,
properties=None,
defaults=None,
custom_name_mapping: Optional[Dict[str, Any]] = None,
add_delay: bool = True,
filter_faulty: bool = True,
Expand All @@ -44,9 +41,9 @@ def convert_to_target(
These objects are usually components of the legacy :class:`.BackendV1` model.
Args:
configuration: Backend configuration as ``BackendConfiguration``
properties: Backend property dictionary or ``BackendProperties``
defaults: Backend pulse defaults dictionary or ``PulseDefaults``
configuration (BackendConfiguration): Backend configuration as ``BackendConfiguration``
properties (BackendProperties): Backend property dictionary or ``BackendProperties``
defaults (PulseDefaults): Backend pulse defaults dictionary or ``PulseDefaults``
custom_name_mapping: A name mapping must be supplied for the operation
not included in Qiskit Standard Gate name mapping, otherwise the operation
will be dropped in the resulting ``Target`` object.
Expand Down Expand Up @@ -298,7 +295,7 @@ def _get_value(prop_dict, prop_name):


def qubit_props_list_from_props(
properties: BackendProperties,
properties,
) -> List[QubitProperties]:
"""Uses BackendProperties to construct
and return a list of QubitProperties.
Expand Down
3 changes: 1 addition & 2 deletions qiskit/transpiler/passes/synthesis/unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.dagcircuit.dagcircuit import DAGCircuit, DAGOpNode
from qiskit.exceptions import QiskitError
from qiskit.providers.models import BackendProperties
from qiskit.quantum_info import Operator
from qiskit.synthesis.one_qubit import one_qubit_decompose
from qiskit.synthesis.two_qubit.xx_decompose import XXDecomposer, XXEmbodiments
Expand Down Expand Up @@ -318,7 +317,7 @@ def __init__(
basis_gates: list[str] = None,
approximation_degree: float | None = 1.0,
coupling_map: CouplingMap = None,
backend_props: BackendProperties = None,
backend_props=None,
pulse_optimize: bool | None = None,
natural_direction: bool | None = None,
synth_gates: list[str] | None = None,
Expand Down
8 changes: 5 additions & 3 deletions qiskit/transpiler/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
# import QubitProperties here to provide convenience alias for building a
# full target
from qiskit.providers.backend import QubitProperties # pylint: disable=unused-import
from qiskit.providers.models.backendproperties import BackendProperties
from qiskit.utils import deprecate_func

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -933,7 +932,7 @@ def from_configuration(
num_qubits: int | None = None,
coupling_map: CouplingMap | None = None,
inst_map: InstructionScheduleMap | None = None,
backend_properties: BackendProperties | None = None,
backend_properties=None,
instruction_durations: InstructionDurations | None = None,
concurrent_measurements: Optional[List[List[int]]] = None,
dt: float | None = None,
Expand Down Expand Up @@ -973,7 +972,8 @@ def from_configuration(
on the instructions from the pair of ``basis_gates`` and
``coupling_map``. If you want to define a custom gate for
a particular qubit or qubit pair, you can manually build :class:`.Target`.
backend_properties: The :class:`~.BackendProperties` object which is
backend_properties (BackendProperties or None): The :class:`~.BackendProperties` object
which is
used for instruction properties and qubit properties.
If specified and instruction properties are intended to be used
then the ``coupling_map`` argument must be specified. This is
Expand Down Expand Up @@ -1256,6 +1256,8 @@ def target_to_backend_properties(target: Target):
with warnings.catch_warnings():
# This raises BackendProperties internally
warnings.filterwarnings("ignore", category=DeprecationWarning)
from qiskit.providers.models.backendproperties import BackendProperties

return BackendProperties.from_dict(properties_dict)
else:
return None

0 comments on commit 921ea6c

Please sign in to comment.