Skip to content

Commit

Permalink
Remove deprecated code in 0.19 (Qiskit#10791)
Browse files Browse the repository at this point in the history
* remove-deprecated-code-in-0.19

* update docs

* Apply suggestions from code review

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* remove unused function

---------

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
  • Loading branch information
doublehoon and 1ucian0 authored Sep 16, 2023
1 parent 4e49a56 commit 2d3632f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 53 deletions.
4 changes: 2 additions & 2 deletions qiskit/compiler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from qiskit.providers.backend import Backend
from qiskit.pulse import Instruction, LoConfig, Schedule, ScheduleBlock
from qiskit.pulse.channels import PulseChannel
from qiskit.qobj import Qobj, QobjHeader
from qiskit.qobj import QasmQobj, PulseQobj, QobjHeader
from qiskit.qobj.utils import MeasLevel, MeasReturnType

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -74,7 +74,7 @@ def assemble(
parametric_pulses: Optional[List[str]] = None,
init_qubits: bool = True,
**run_config: Dict,
) -> Qobj:
) -> Union[QasmQobj, PulseQobj]:
"""Assemble a list of circuits or pulse schedules into a ``Qobj``.
This function serializes the payloads, which could be either circuits or schedules,
Expand Down
14 changes: 1 addition & 13 deletions qiskit/providers/models/backendconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
DriveChannel,
MeasureChannel,
)
from qiskit.utils.deprecation import deprecate_arg


class GateConfig:
Expand Down Expand Up @@ -831,22 +830,13 @@ def acquire(self, qubit: int) -> AcquireChannel:
raise BackendConfigurationError(f"Invalid index for {qubit}-qubit systems.")
return AcquireChannel(qubit)

@deprecate_arg(
"channel",
since="0.19.0",
additional_msg=(
"Instead, use the ``qubits`` argument. This method will now return accurate "
"ControlChannels determined by qubit indices."
),
)
def control(self, qubits: Iterable[int] = None, channel: int = None) -> List[ControlChannel]:
def control(self, qubits: Iterable[int] = None) -> List[ControlChannel]:
"""
Return the secondary drive channel for the given qubit -- typically utilized for
controlling multiqubit interactions. This channel is derived from other channels.
Args:
qubits: Tuple or list of qubits of the form `(control_qubit, target_qubit)`.
channel: Deprecated.
Raises:
BackendConfigurationError: If the ``qubits`` is not a part of the system or if
Expand All @@ -855,8 +845,6 @@ def control(self, qubits: Iterable[int] = None, channel: int = None) -> List[Con
Returns:
List of control channels.
"""
if channel is not None:
qubits = [channel]
try:
if isinstance(qubits, list):
qubits = tuple(qubits)
Expand Down
12 changes: 0 additions & 12 deletions qiskit/qobj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
.. autosummary::
:toctree: ../stubs/
Qobj
QobjExperimentHeader
QobjHeader
Expand Down Expand Up @@ -74,14 +73,3 @@
from qiskit.qobj.qasm_qobj import QasmQobjExperiment
from qiskit.qobj.qasm_qobj import QasmQobjConfig
from qiskit.qobj.qasm_qobj import QasmQobjExperimentConfig

from qiskit.utils.deprecation import deprecate_func


class Qobj(QasmQobj):
"""A backwards compat alias for QasmQobj."""

@deprecate_func(additional_msg="Instead, use QasmQobj or PulseQobj", since="0.19.0")
def __init__(self, qobj_id=None, config=None, experiments=None, header=None):
"""Initialize a Qobj object."""
super().__init__(qobj_id=qobj_id, config=config, experiments=experiments, header=header)
28 changes: 4 additions & 24 deletions qiskit/transpiler/instruction_durations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@

import qiskit.circuit
from qiskit.circuit import Barrier, Delay
from qiskit.circuit import Instruction, Qubit, ParameterExpression
from qiskit.circuit import Instruction, ParameterExpression
from qiskit.circuit.duration import duration_in_dt
from qiskit.providers import Backend
from qiskit.transpiler.exceptions import TranspilerError
from qiskit.utils.deprecation import deprecate_arg
from qiskit.utils.units import apply_prefix


def _is_deprecated_qubits_argument(qubits: Union[int, list[int], Qubit, list[Qubit]]) -> bool:
if isinstance(qubits, (int, Qubit)):
qubits = [qubits]
return isinstance(qubits[0], Qubit)


class InstructionDurations:
"""Helper class to provide durations of instructions for scheduling.
Expand Down Expand Up @@ -130,7 +123,6 @@ def update(self, inst_durations: "InstructionDurationsType" | None, dt: float =
)
else:
for i, items in enumerate(inst_durations):

if not isinstance(items[-1], str):
items = (*items, "dt") # set default unit

Expand Down Expand Up @@ -170,19 +162,10 @@ def update(self, inst_durations: "InstructionDurationsType" | None, dt: float =

return self

@deprecate_arg(
"qubits",
deprecation_description=(
"Using a Qubit or List[Qubit] for the ``qubits`` argument to InstructionDurations.get()"
),
additional_msg="Instead, use an integer for the qubit index.",
since="0.19.0",
predicate=_is_deprecated_qubits_argument,
)
def get(
self,
inst: str | qiskit.circuit.Instruction,
qubits: int | list[int] | Qubit | list[Qubit] | list[int | Qubit],
qubits: int | list[int],
unit: str = "dt",
parameters: list[float] | None = None,
) -> float:
Expand All @@ -192,7 +175,7 @@ def get(
Args:
inst: An instruction or its name to be queried.
qubits: Qubits or its indices that the instruction acts on.
qubits: Qubit indices that the instruction acts on.
unit: The unit of duration to be returned. It must be 's' or 'dt'.
parameters: The value of the parameters of the desired instruction.
Expand All @@ -212,12 +195,9 @@ def get(
else:
inst_name = inst

if isinstance(qubits, (int, Qubit)):
if isinstance(qubits, int):
qubits = [qubits]

if isinstance(qubits[0], Qubit):
qubits = [q.index for q in qubits]

try:
return self._get(inst_name, qubits, unit, parameters)
except TranspilerError as ex:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/utils/quantum_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import numpy as np

from qiskit.qobj import Qobj
from qiskit.qobj import QasmQobj, PulseQobj
from qiskit.utils import circuit_utils
from qiskit.exceptions import QiskitError
from qiskit.utils.backend_utils import (
Expand Down Expand Up @@ -451,7 +451,7 @@ def transpile(self, circuits, pass_manager=None):

return transpiled_circuits

def assemble(self, circuits) -> Qobj:
def assemble(self, circuits) -> Union[QasmQobj, PulseQobj]:
"""assemble circuits"""
# pylint: disable=cyclic-import
from qiskit import compiler
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
upgrade:
- |
The argument ``qubits`` in the method :meth:`qiskit.transpiler.instruction_durations.InstructionDurations.get`, does not accept :class:`.Qubit` (or a list of them) any more. This functionality was deprecated in Qiskit 0.33 (with Terra 0.19), released on Dec 2021. Instead, use an integer for the qubit indices.
- |
The argument ``channel`` in the method :meth:`qiskit.providers.models.backendconfiguration.PulseBackendConfiguration.control` is removed. It was deprecated in Qiskit 0.33 (with Terra 0.19), released on Dec 2021. Instead use the ``qubits`` argument.
- |
The class ``qiskit.qobj.Qobj`` is removed. It was deprecated in Qiskit 0.33 (with Terra 0.19), released on Dec 2021. Instead, use :class:`qiskit.qobj.QasmQobj` or :class:`qiskit.qobj.PulseQobj`.

0 comments on commit 2d3632f

Please sign in to comment.