From 53e112d6cca4c8460b8f72e39e37e645c15004c8 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Sat, 21 Dec 2024 16:11:16 +0100 Subject: [PATCH 1/2] add docuemntation about instruction duration --- qiskit/circuit/instruction.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qiskit/circuit/instruction.py b/qiskit/circuit/instruction.py index e1df54c2cb99..5c88cb5e2d13 100644 --- a/qiskit/circuit/instruction.py +++ b/qiskit/circuit/instruction.py @@ -64,13 +64,18 @@ class Instruction(Operation): def __init__(self, name, num_qubits, num_clbits, params, duration=None, unit="dt", label=None): """Create a new instruction. + .. deprecated:: 1.3 + The parameters ``duration`` and ``unit`` are deprecated since + Qiskit 1.3, and they will be removed in 2.0 or more later. + An instruction's duration is defined in a backend's Target object. + Args: name (str): instruction name num_qubits (int): instruction's qubit width num_clbits (int): instruction's clbit width params (list[int|float|complex|str|ndarray|list|ParameterExpression]): list of parameters - duration (int or float): instruction's duration. it must be integer if ``unit`` is 'dt' + duration (int|float): instruction's duration. it must be integer if ``unit`` is ``'dt'`` unit (str): time unit of duration label (str or None): An optional label for identifying the instruction. From 651c54317b720341a9229a37f0fa667df0cd418c Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 24 Dec 2024 15:08:50 +0100 Subject: [PATCH 2/2] more docs and some spelling --- qiskit/circuit/instruction.py | 5 +++-- qiskit/pulse/utils.py | 2 +- qiskit/visualization/timeline/core.py | 8 ++++++++ qiskit/visualization/timeline/interface.py | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/qiskit/circuit/instruction.py b/qiskit/circuit/instruction.py index 5c88cb5e2d13..af0c3798b5c7 100644 --- a/qiskit/circuit/instruction.py +++ b/qiskit/circuit/instruction.py @@ -75,8 +75,9 @@ def __init__(self, name, num_qubits, num_clbits, params, duration=None, unit="dt num_clbits (int): instruction's clbit width params (list[int|float|complex|str|ndarray|list|ParameterExpression]): list of parameters - duration (int|float): instruction's duration. it must be integer if ``unit`` is ``'dt'`` - unit (str): time unit of duration + duration (int|float): (DEPRECATED) instruction's duration. it must be + integer if ``unit`` is ``'dt'`` + unit (str): (DEPRECATED) time unit of duration label (str or None): An optional label for identifying the instruction. Raises: diff --git a/qiskit/pulse/utils.py b/qiskit/pulse/utils.py index 5f345917761e..2f2093817c8a 100644 --- a/qiskit/pulse/utils.py +++ b/qiskit/pulse/utils.py @@ -51,7 +51,7 @@ def format_parameter_value( decimal: Number of digit to round returned value. Returns: - Value casted to non-parameter data type, when possible. + Value cast to non-parameter data type, when possible. """ if isinstance(operand, ParameterExpression): try: diff --git a/qiskit/visualization/timeline/core.py b/qiskit/visualization/timeline/core.py index 71e2735559a8..08b71ec112d5 100644 --- a/qiskit/visualization/timeline/core.py +++ b/qiskit/visualization/timeline/core.py @@ -142,6 +142,14 @@ def add_data(self, data: drawings.ElementaryData): def load_program(self, program: circuit.QuantumCircuit, target: Target | None = None): """Load quantum circuit and create drawing.. + .. deprecated:: 1.3 + Visualizing un-scheduled circuit with timeline drawer has been deprecated in Qiskit 1.3. + This circuit should be transpiled with scheduler though it consists of + instructions with explicit durations. + + .. deprecated:: 1.3 + Target with duration-less operations are going to error in Qiskit 2.0. + Args: program: Scheduled circuit object to draw. target: The target the circuit is scheduled for. This contains backend information diff --git a/qiskit/visualization/timeline/interface.py b/qiskit/visualization/timeline/interface.py index 686e0fe1d810..93b319926c2c 100644 --- a/qiskit/visualization/timeline/interface.py +++ b/qiskit/visualization/timeline/interface.py @@ -52,6 +52,10 @@ def draw( ): r"""Generate visualization data for scheduled circuit programs. + .. deprecated:: 1.3 + The ``target`` parameter needs to be specified in Qiskit 2.0 in order get the duration of + the instructions. + Args: program: Program to visualize. This program should be a `QuantumCircuit` which is transpiled with a scheduling_method, thus containing gate time information. @@ -292,7 +296,7 @@ def draw( Examples: To visualize a scheduled circuit program, you can call this function with set of - control arguments. Most of appearance of the output image can be controlled by the + control arguments. Most of the appearance of the output image can be controlled by the stylesheet. Drawing with the default stylesheet.