From ccf0c023088d91c02cf4b5b7133141b6ffcf271e Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 3 Aug 2023 10:50:56 +0200 Subject: [PATCH 01/11] small doc fixes --- qiskit/circuit/gate.py | 8 ++++---- qiskit/circuit/instruction.py | 2 +- qiskit/converters/circuit_to_dag.py | 2 +- qiskit/converters/circuit_to_dagdependency.py | 2 +- qiskit/dagcircuit/__init__.py | 4 ++-- qiskit/dagcircuit/dagdependency.py | 7 +++---- qiskit/execute_function.py | 11 +++++------ qiskit/extensions/quantum_initializer/squ.py | 11 +++++------ qiskit/visualization/pass_manager_visualization.py | 4 ++-- 9 files changed, 24 insertions(+), 27 deletions(-) diff --git a/qiskit/circuit/gate.py b/qiskit/circuit/gate.py index 3bfd40f15999..4cff93e6bbee 100644 --- a/qiskit/circuit/gate.py +++ b/qiskit/circuit/gate.py @@ -100,15 +100,15 @@ def control( """Return controlled version of gate. See :class:`.ControlledGate` for usage. Args: - num_ctrl_qubits: number of controls to add to gate (default=1) + num_ctrl_qubits: number of controls to add to gate (default: 1) label: optional gate label ctrl_state: The control state in decimal or as a bitstring - (e.g. '111'). If None, use 2**num_ctrl_qubits-1. + (e.g. ``'111'``). If None, use 2**``num_ctrl_qubits``-1. Returns: qiskit.circuit.ControlledGate: Controlled version of gate. This default algorithm - uses num_ctrl_qubits-1 ancillae qubits so returns a gate of size - num_qubits + 2*num_ctrl_qubits - 1. + uses ``num_ctrl_qubits``-1 ancillae qubits so returns a gate of size + ``num_qubits`` + 2``*num_ctrl_qubits`` - 1. Raises: QiskitError: unrecognized mode or invalid ctrl_state diff --git a/qiskit/circuit/instruction.py b/qiskit/circuit/instruction.py index 6b74dacfaab8..93cfbeb3dd51 100644 --- a/qiskit/circuit/instruction.py +++ b/qiskit/circuit/instruction.py @@ -460,7 +460,7 @@ def qasm(self): """Return a default OpenQASM string for the instruction. Derived instructions may override this to print in a - different format (e.g. measure q[0] -> c[0];). + different format (e.g. ``measure q[0] -> c[0];``). """ name_param = self.name if self.params: diff --git a/qiskit/converters/circuit_to_dag.py b/qiskit/converters/circuit_to_dag.py index a7410f3e7698..5cb2332bcfd8 100644 --- a/qiskit/converters/circuit_to_dag.py +++ b/qiskit/converters/circuit_to_dag.py @@ -17,7 +17,7 @@ def circuit_to_dag(circuit, copy_operations=True, *, qubit_order=None, clbit_order=None): - """Build a ``DAGCircuit`` object from a ``QuantumCircuit``. + """Build a :class:`~.DAGCircuit` object from a :class:`~.QuantumCircuit`. Args: circuit (QuantumCircuit): the input circuit. diff --git a/qiskit/converters/circuit_to_dagdependency.py b/qiskit/converters/circuit_to_dagdependency.py index 17c9de10ef55..7095d4773112 100644 --- a/qiskit/converters/circuit_to_dagdependency.py +++ b/qiskit/converters/circuit_to_dagdependency.py @@ -16,7 +16,7 @@ def circuit_to_dagdependency(circuit, create_preds_and_succs=True): - """Build a ``DAGDependency`` object from a ``QuantumCircuit``. + """Build a ``DAGDependency`` object from a :class:`~.QuantumCircuit`. Args: circuit (QuantumCircuit): the input circuit. diff --git a/qiskit/dagcircuit/__init__.py b/qiskit/dagcircuit/__init__.py index 2c5ed3dbd03e..fa991d1f44fe 100644 --- a/qiskit/dagcircuit/__init__.py +++ b/qiskit/dagcircuit/__init__.py @@ -17,8 +17,8 @@ .. currentmodule:: qiskit.dagcircuit -DAG Circuits -============ +DAG (directed acyclic graph) Circuits +===================================== .. autosummary:: :toctree: ../stubs/ diff --git a/qiskit/dagcircuit/dagdependency.py b/qiskit/dagcircuit/dagdependency.py index 8082fdadfa75..802fcc44c395 100644 --- a/qiskit/dagcircuit/dagdependency.py +++ b/qiskit/dagcircuit/dagdependency.py @@ -48,7 +48,7 @@ class DAGDependency: - """Object to represent a quantum circuit as a directed acyclic graph + """Object to represent a quantum circuit as a DAG via operation dependencies (i.e. lack of commutation). The nodes in the graph are operations represented by quantum gates. @@ -143,7 +143,7 @@ def calibrations(self): """Return calibration dictionary. The custom pulse definition of a given gate is of the form - {'gate_name': {(qubits, params): schedule}} + ``{'gate_name': {(qubits, params): schedule}}``. """ return dict(self._calibrations) @@ -530,8 +530,7 @@ def draw(self, scale=0.7, filename=None, style="color"): 'color' (default): color input/output/op nodes Returns: - Ipython.display.Image: if in Jupyter notebook and not saving to file, - otherwise None. + Ipython.display.Image: if in Jupyter notebook and not saving to file, otherwise None. """ from qiskit.visualization.dag_visualization import dag_drawer diff --git a/qiskit/execute_function.py b/qiskit/execute_function.py index 51ecc68246b5..8c4da2064d4d 100644 --- a/qiskit/execute_function.py +++ b/qiskit/execute_function.py @@ -90,18 +90,17 @@ def execute( basis_gates (list[str]): List of basis gate names to unroll to. - e.g: ``['u1', 'u2', 'u3', 'cx']`` + e.g: ``['u1', 'u2', 'u3', 'cx']``. If ``None``, do not unroll. coupling_map (CouplingMap or list): Coupling map (perhaps custom) to target in mapping. Multiple formats are supported: - #. CouplingMap instance - #. list - Must be given as an adjacency matrix, where each entry + #. :class:`~.CouplingMap` instance + #. ``list``: + must be given as an adjacency matrix, where each entry specifies all two-qubit interactions supported by backend - e.g: - ``[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]`` + e.g: ``[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]`` backend_properties (BackendProperties): Properties returned by a backend, including information on gate diff --git a/qiskit/extensions/quantum_initializer/squ.py b/qiskit/extensions/quantum_initializer/squ.py index 2ae88682743e..e4722fd36d46 100644 --- a/qiskit/extensions/quantum_initializer/squ.py +++ b/qiskit/extensions/quantum_initializer/squ.py @@ -31,12 +31,11 @@ class SingleQubitUnitary(Gate): - """ - u = 2*2 unitary (given as a (complex) numpy.ndarray) - - mode - determines the used decomposition by providing the rotation axes - - up_to_diagonal - the single-qubit unitary is decomposed up to a diagonal matrix, + """Single-qubit unitary. + Args: + unitary_matrix: 2*2 unitary (given as a (complex) ``numpy.ndarray``). + mode: determines the used decomposition by providing the rotation axes. + up_to_diagonal: the single-qubit unitary is decomposed up to a diagonal matrix, i.e. a unitary u' is implemented such that there exists a 2*2 diagonal gate d with u = d.dot(u'). """ diff --git a/qiskit/visualization/pass_manager_visualization.py b/qiskit/visualization/pass_manager_visualization.py index 6765c199e7c5..f043e3a04551 100644 --- a/qiskit/visualization/pass_manager_visualization.py +++ b/qiskit/visualization/pass_manager_visualization.py @@ -31,8 +31,8 @@ def pass_manager_drawer(pass_manager, filename=None, style=None, raw=False): """ Draws the pass manager. - This function needs `pydot `__, which in turn needs - `Graphviz `__ to be installed. + This function needs `pydot `_, which in turn needs + `Graphviz `_ to be installed. Args: pass_manager (PassManager): the pass manager to be drawn From 628443151bb5e4e5e540f37645abf50372780ac2 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 8 Aug 2023 13:25:57 +0200 Subject: [PATCH 02/11] more small changes --- qiskit/circuit/gate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/circuit/gate.py b/qiskit/circuit/gate.py index 4cff93e6bbee..3c0f216a494b 100644 --- a/qiskit/circuit/gate.py +++ b/qiskit/circuit/gate.py @@ -100,14 +100,14 @@ def control( """Return controlled version of gate. See :class:`.ControlledGate` for usage. Args: - num_ctrl_qubits: number of controls to add to gate (default: 1) + num_ctrl_qubits: number of controls to add to gate (default:: 1) label: optional gate label ctrl_state: The control state in decimal or as a bitstring (e.g. ``'111'``). If None, use 2**``num_ctrl_qubits``-1. Returns: qiskit.circuit.ControlledGate: Controlled version of gate. This default algorithm - uses ``num_ctrl_qubits``-1 ancillae qubits so returns a gate of size + uses ``num_ctrl_qubits``-1 ancilla qubits so returns a gate of size ``num_qubits`` + 2``*num_ctrl_qubits`` - 1. Raises: From d1836a99afb67239be0d9a8cbd86d3b01e2fcacc Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 15 Aug 2023 13:58:55 +0200 Subject: [PATCH 03/11] Update qiskit/extensions/quantum_initializer/squ.py Co-authored-by: Julien Gacon --- qiskit/extensions/quantum_initializer/squ.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiskit/extensions/quantum_initializer/squ.py b/qiskit/extensions/quantum_initializer/squ.py index e4722fd36d46..0c9a380f0a2e 100644 --- a/qiskit/extensions/quantum_initializer/squ.py +++ b/qiskit/extensions/quantum_initializer/squ.py @@ -32,6 +32,7 @@ class SingleQubitUnitary(Gate): """Single-qubit unitary. + Args: unitary_matrix: 2*2 unitary (given as a (complex) ``numpy.ndarray``). mode: determines the used decomposition by providing the rotation axes. From a504bb0c3fb9ccd722ac172906e9932f6098a98d Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Wed, 16 Aug 2023 14:18:24 +0200 Subject: [PATCH 04/11] improve gate docs --- qiskit/circuit/gate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qiskit/circuit/gate.py b/qiskit/circuit/gate.py index 3c0f216a494b..783536ba319b 100644 --- a/qiskit/circuit/gate.py +++ b/qiskit/circuit/gate.py @@ -100,15 +100,15 @@ def control( """Return controlled version of gate. See :class:`.ControlledGate` for usage. Args: - num_ctrl_qubits: number of controls to add to gate (default:: 1) + num_ctrl_qubits: number of controls to add to gate (default: ``1``) label: optional gate label ctrl_state: The control state in decimal or as a bitstring - (e.g. ``'111'``). If None, use 2**``num_ctrl_qubits``-1. + (e.g. ``'111'``). If ``None``, use ``2**num_ctrl_qubits-1``. Returns: qiskit.circuit.ControlledGate: Controlled version of gate. This default algorithm - uses ``num_ctrl_qubits``-1 ancilla qubits so returns a gate of size - ``num_qubits`` + 2``*num_ctrl_qubits`` - 1. + uses ``num_ctrl_qubits-1`` ancilla qubits so returns a gate of size + ``num_qubits + 2*num_ctrl_qubits - 1``. Raises: QiskitError: unrecognized mode or invalid ctrl_state From d9aed42e7f887d2ee2cd6f12d4931abe77c13896 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 17 Aug 2023 09:45:45 +0200 Subject: [PATCH 05/11] Apply suggestions from code review Co-authored-by: Julien Gacon --- qiskit/extensions/quantum_initializer/squ.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qiskit/extensions/quantum_initializer/squ.py b/qiskit/extensions/quantum_initializer/squ.py index 0c9a380f0a2e..b4dceef8f1b6 100644 --- a/qiskit/extensions/quantum_initializer/squ.py +++ b/qiskit/extensions/quantum_initializer/squ.py @@ -34,11 +34,11 @@ class SingleQubitUnitary(Gate): """Single-qubit unitary. Args: - unitary_matrix: 2*2 unitary (given as a (complex) ``numpy.ndarray``). + unitary_matrix: :math:`2 \times 2` unitary (given as a (complex) ``numpy.ndarray``). mode: determines the used decomposition by providing the rotation axes. up_to_diagonal: the single-qubit unitary is decomposed up to a diagonal matrix, - i.e. a unitary u' is implemented such that there exists a 2*2 diagonal - gate d with u = d.dot(u'). + i.e. a unitary :math:`U'` is implemented such that there exists a diagonal + matrix :math:`D` with :math:`U = D U'`. """ def __init__(self, unitary_matrix, mode="ZYZ", up_to_diagonal=False): From 468f8ee1d8c6d3392874717c8432b57526314a20 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 14 Sep 2023 16:00:06 +0200 Subject: [PATCH 06/11] Update qiskit/converters/circuit_to_dag.py --- qiskit/converters/circuit_to_dag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/converters/circuit_to_dag.py b/qiskit/converters/circuit_to_dag.py index 5cb2332bcfd8..adcf3f589125 100644 --- a/qiskit/converters/circuit_to_dag.py +++ b/qiskit/converters/circuit_to_dag.py @@ -17,7 +17,7 @@ def circuit_to_dag(circuit, copy_operations=True, *, qubit_order=None, clbit_order=None): - """Build a :class:`~.DAGCircuit` object from a :class:`~.QuantumCircuit`. + """Build a :class:`.DAGCircuit` object from a :class:`.QuantumCircuit`. Args: circuit (QuantumCircuit): the input circuit. From 6edba2b926d30deb1a91188587ddf274c500c26f Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 14 Sep 2023 16:00:29 +0200 Subject: [PATCH 07/11] Update qiskit/execute_function.py --- qiskit/execute_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/execute_function.py b/qiskit/execute_function.py index 8c4da2064d4d..0706b106bd23 100644 --- a/qiskit/execute_function.py +++ b/qiskit/execute_function.py @@ -96,7 +96,7 @@ def execute( coupling_map (CouplingMap or list): Coupling map (perhaps custom) to target in mapping. Multiple formats are supported: - #. :class:`~.CouplingMap` instance + #. :class:`.CouplingMap` instance #. ``list``: must be given as an adjacency matrix, where each entry specifies all two-qubit interactions supported by backend From 430d0b3f709fa10879133e76f0fc75f55df9fe9e Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Sat, 16 Sep 2023 23:21:40 +0200 Subject: [PATCH 08/11] Circuits as Directed Acyclic Graphs --- qiskit/dagcircuit/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/dagcircuit/__init__.py b/qiskit/dagcircuit/__init__.py index 3f49b728fabf..cd2b75f6f6af 100644 --- a/qiskit/dagcircuit/__init__.py +++ b/qiskit/dagcircuit/__init__.py @@ -17,8 +17,8 @@ .. currentmodule:: qiskit.dagcircuit -DAG (directed acyclic graph) Circuits -===================================== +Circuits as Directed Acyclic Graphs +=================================== .. autosummary:: :toctree: ../stubs/ From 16b75c78ec152b33f79ceb47fd2016deb7a18559 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Sat, 16 Sep 2023 23:23:03 +0200 Subject: [PATCH 09/11] a quantum circuit as a Directed Acyclic Graphs (DAG --- qiskit/dagcircuit/dagdependency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/dagcircuit/dagdependency.py b/qiskit/dagcircuit/dagdependency.py index 802fcc44c395..ae838a5c8941 100644 --- a/qiskit/dagcircuit/dagdependency.py +++ b/qiskit/dagcircuit/dagdependency.py @@ -48,7 +48,7 @@ class DAGDependency: - """Object to represent a quantum circuit as a DAG + """Object to represent a quantum circuit as a Directed Acyclic Graphs (DAG) via operation dependencies (i.e. lack of commutation). The nodes in the graph are operations represented by quantum gates. From c6af56cb58ac9edbbbea7da9e9dd7b72d7b48e84 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Sat, 16 Sep 2023 23:25:47 +0200 Subject: [PATCH 10/11] __ --- qiskit/visualization/pass_manager_visualization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/visualization/pass_manager_visualization.py b/qiskit/visualization/pass_manager_visualization.py index f043e3a04551..6b166ac85ffc 100644 --- a/qiskit/visualization/pass_manager_visualization.py +++ b/qiskit/visualization/pass_manager_visualization.py @@ -31,8 +31,8 @@ def pass_manager_drawer(pass_manager, filename=None, style=None, raw=False): """ Draws the pass manager. - This function needs `pydot `_, which in turn needs - `Graphviz `_ to be installed. + This function needs `pydot `__, which in turn needs + `Graphviz `__ to be installed. Args: pass_manager (PassManager): the pass manager to be drawn From 10ccfb962f74ffd9875e57d5237194c469c2d3a5 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Mon, 18 Sep 2023 12:50:05 +0100 Subject: [PATCH 11/11] Fix errant plural --- qiskit/dagcircuit/dagdependency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/dagcircuit/dagdependency.py b/qiskit/dagcircuit/dagdependency.py index ae838a5c8941..8e4904c2b8b2 100644 --- a/qiskit/dagcircuit/dagdependency.py +++ b/qiskit/dagcircuit/dagdependency.py @@ -48,7 +48,7 @@ class DAGDependency: - """Object to represent a quantum circuit as a Directed Acyclic Graphs (DAG) + """Object to represent a quantum circuit as a Directed Acyclic Graph (DAG) via operation dependencies (i.e. lack of commutation). The nodes in the graph are operations represented by quantum gates.