-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some doc formatting and link, mostly on quantumcircuit.py file #9771
Changes from 1 commit
bff2e1b
da9201a
c7d6ff9
8dda1b9
9020e3e
65c916c
f674869
6c09254
6a33145
decf879
a6acd84
e0ef3ff
302983a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,11 +130,11 @@ class QuantumCircuit: | |
A circuit is a list of instructions bound to some registers. | ||
|
||
Args: | ||
regs (list(:class:`Register`) or list(``int``) or list(list(:class:`Bit`))): The | ||
regs (list(:class:`.Register`) or list(``int``) or list(list(:class:`.Bit`))): The | ||
registers to be included in the circuit. | ||
|
||
* If a list of :class:`Register` objects, represents the :class:`QuantumRegister` | ||
and/or :class:`ClassicalRegister` objects to include in the circuit. | ||
* If a list of :class:`.Register` objects, represents the :class:`.QuantumRegister` | ||
and/or :class:`.ClassicalRegister` objects to include in the circuit. | ||
|
||
For example: | ||
|
||
|
@@ -151,8 +151,8 @@ class QuantumCircuit: | |
* ``QuantumCircuit(4) # A QuantumCircuit with 4 qubits`` | ||
* ``QuantumCircuit(4, 3) # A QuantumCircuit with 4 qubits and 3 classical bits`` | ||
|
||
* If a list of python lists containing :class:`Bit` objects, a collection of | ||
:class:`Bit` s to be added to the circuit. | ||
* If a list of python lists containing :class:`.Bit` objects, a collection of | ||
:class:`.Bit` s to be added to the circuit. | ||
|
||
|
||
name (str): the name of the quantum circuit. If not set, an | ||
|
@@ -1218,7 +1218,7 @@ def append( | |
|
||
Raises: | ||
CircuitError: if the operation passed is not an instance of | ||
:class:`~.circuit..Instruction`. | ||
:class:`~.circuit.Instruction`. | ||
""" | ||
if isinstance(instruction, CircuitInstruction): | ||
operation = instruction.operation | ||
|
@@ -1858,10 +1858,10 @@ def draw( | |
Default is True, except for when ``output`` is set to ``"text"``. | ||
wire_order (list): Optional. A list of integers used to reorder the display | ||
of the bits. The list must have an entry for every bit with the bits | ||
in the range 0 to (num_qubits + num_clbits). | ||
in the range 0 to (``num_qubits`` + ``num_clbits``). | ||
|
||
Returns: | ||
:class:`TextDrawing` or :class:`matplotlib.figure` or :class:`PIL.Image` or | ||
:class:`.TextDrawing` or :class:`matplotlib.figure` or :class:`PIL.Image` or | ||
:class:`str`: | ||
1ucian0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `TextDrawing` (output='text') | ||
|
@@ -2803,8 +2803,8 @@ def _rebind_definition( | |
self._rebind_definition(inner.operation, parameter, value) | ||
|
||
def barrier(self, *qargs: QubitSpecifier, label=None) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.Barrier`. If qargs is empty, applies to all qubits in the | ||
circuit. | ||
"""Apply :class:`~qiskit.circuit.library.Barrier`. If ``qargs`` is empty, applies to all qubits | ||
in the circuit. | ||
|
||
Args: | ||
qargs (QubitSpecifier): Specification for one or more qubit arguments. | ||
|
@@ -2840,14 +2840,15 @@ def delay( | |
qarg: Optional[QubitSpecifier] = None, | ||
unit: str = "dt", | ||
) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.Delay`. If qarg is None, applies to all qubits. | ||
"""Apply :class:`~.~qiskit.circuit.library.Delay`. If qarg is ``None``, applies to all qubits. | ||
1ucian0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
When applying to multiple qubits, delays with the same duration will be created. | ||
|
||
Args: | ||
duration (int or float or ParameterExpression): duration of the delay. | ||
qarg (Object): qubit argument to apply this delay. | ||
unit (str): unit of the duration. Supported units: 's', 'ms', 'us', 'ns', 'ps', 'dt'. | ||
Default is ``dt``, i.e. integer time unit depending on the target backend. | ||
unit (str): unit of the duration. Supported units: ``'s'``, ``'ms'``, ``'us'``, | ||
``'ns'``, ``'ps'``, and ``'dt'``. Default is ``'dt'``, i.e. integer time unit | ||
depending on the target backend. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need indentations here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes in "Args", no in "Returns" - hooray for consistency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixing this in c7d6ff9 |
||
|
||
Returns: | ||
qiskit.circuit.InstructionSet: handle to the added instructions. | ||
|
@@ -2953,7 +2954,7 @@ def id(self, qubit: QubitSpecifier) -> InstructionSet: # pylint: disable=invali | |
return self.i(qubit) | ||
|
||
def ms(self, theta: ParameterValueType, qubits: Sequence[QubitSpecifier]) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.library.generalized_gates.gms.MSGate`. | ||
"""Apply :class:`~qiskit.circuit.library.MSGate`. | ||
|
||
For the full matrix form of this gate, see the underlying gate documentation. | ||
|
||
|
@@ -3074,9 +3075,9 @@ def rv( | |
rotation in radians. | ||
|
||
Args: | ||
vx: x-compenent of the rotation axis. | ||
vy: y-compenent of the rotation axis. | ||
vz: z-compenent of the rotation axis. | ||
vx: x-component of the rotation axis. | ||
vy: y-component of the rotation axis. | ||
vz: z-component of the rotation axis. | ||
qubit: The qubit(s) to apply the gate to. | ||
|
||
Returns: | ||
|
@@ -3507,8 +3508,8 @@ def cswap( | |
target_qubit2: The qubit(s) targeted by the gate. | ||
label: The string label of the gate in the circuit. | ||
ctrl_state: | ||
The control state in decimal, or as a bitstring (e.g. '1'). Defaults to controlling | ||
on the '1' state. | ||
The control state in decimal, or as a bitstring (e.g. ``'1'``). Defaults to controlling | ||
on the ``'1'`` state. | ||
|
||
Returns: | ||
A handle to the instructions created. | ||
|
@@ -3849,10 +3850,10 @@ def mcx( | |
The multi-cX gate can be implemented using different techniques, which use different numbers | ||
of ancilla qubits and have varying circuit depth. These modes are: | ||
|
||
- 'noancilla': Requires 0 ancilla qubits. | ||
- 'recursion': Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0. | ||
- 'v-chain': Requires 2 less ancillas than the number of control qubits. | ||
- 'v-chain-dirty': Same as for the clean ancillas (but the circuit will be longer). | ||
- ``'noancilla'``: Requires 0 ancilla qubits. | ||
- ``'recursion'``: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0. | ||
- ``'v-chain'``: Requires 2 less ancillas than the number of control qubits. | ||
- ``'v-chain-dirty'``: Same as for the clean ancillas (but the circuit will be longer). | ||
Comment on lines
-3909
to
+3912
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here about maybe not needing monospace, but again, not important. |
||
|
||
For the full matrix form of this gate, see the underlying gate documentation. | ||
|
||
|
@@ -3927,10 +3928,10 @@ def mct( | |
The multi-cX gate can be implemented using different techniques, which use different numbers | ||
of ancilla qubits and have varying circuit depth. These modes are: | ||
|
||
- 'noancilla': Requires 0 ancilla qubits. | ||
- 'recursion': Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0. | ||
- 'v-chain': Requires 2 less ancillas than the number of control qubits. | ||
- 'v-chain-dirty': Same as for the clean ancillas (but the circuit will be longer). | ||
- ``'noancilla'``: Requires 0 ancilla qubits. | ||
- ``'recursion'``: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0. | ||
- ``'v-chain'``: Requires 2 less ancillas than the number of control qubits. | ||
- ``'v-chain-dirty'``: Same as for the clean ancillas (but the circuit will be longer). | ||
Comment on lines
-3987
to
+3990
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... and here. |
||
|
||
For the full matrix form of this gate, see the underlying gate documentation. | ||
|
||
|
@@ -4305,10 +4306,10 @@ def for_loop( | |
|
||
There are two forms for calling this function. If called with all its arguments (with the | ||
possible exception of ``label``), it will create a | ||
:obj:`~qiskit.circuit.controlflow.ForLoopOp` with the given ``body``. If ``body`` (and | ||
:class:`~.ForLoopOp` with the given ``body``. If ``body`` (and | ||
``qubits`` and ``clbits``) are *not* passed, then this acts as a context manager, which, | ||
when entered, provides a loop variable (unless one is given, in which case it will be | ||
reused) and will automatically build a :obj:`~qiskit.circuit.controlflow.ForLoopOp` when the | ||
reused) and will automatically build a :class:`~.ForLoopOp` when the | ||
scope finishes. In this form, you do not need to keep track of the qubits or clbits you are | ||
using, because the scope will handle it for you. | ||
|
||
|
@@ -4490,7 +4491,7 @@ def if_else( | |
clbits: Sequence[ClbitSpecifier], | ||
label: Optional[str] = None, | ||
) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.controlflow.IfElseOp`. | ||
"""Apply :class:`~.IfElseOp`. | ||
|
||
.. note:: | ||
|
||
|
@@ -4535,7 +4536,7 @@ def if_else( | |
return self.append(IfElseOp(condition, true_body, false_body, label), qubits, clbits) | ||
|
||
def break_loop(self) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.controlflow.BreakLoopOp`. | ||
"""Apply :class:`~.BreakLoopOp`. | ||
|
||
.. warning:: | ||
|
||
|
@@ -4565,7 +4566,7 @@ def break_loop(self) -> InstructionSet: | |
return self.append(BreakLoopOp(self.num_qubits, self.num_clbits), self.qubits, self.clbits) | ||
|
||
def continue_loop(self) -> InstructionSet: | ||
"""Apply :class:`~qiskit.circuit.controlflow.ContinueLoopOp`. | ||
"""Apply :class:`~.ContinueLoopOp`. | ||
|
||
.. warning:: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug in doc that is it not being exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record for others: this is deliberately not exposed documentation - it's an internal private detail of the control-flow builder interface. I just wrote some documentation in the docstrings of the private components for developers who are modifying the code. If we build a "developer documentation" / "architecture" section in the future, we could potentially put it there, but for now it's fine just being effectively a code comment.