Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ select = [
"INP",
# flake8-print
"T20",
# Missing arguments in docstring
"D417",
]
ignore = [
"E402", # module-import-not-at-top-of-file false positives with module docs
Expand Down
3 changes: 3 additions & 0 deletions qiskit/circuit/controlflow/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def __init__(
duration: the final duration of the box.
unit: the unit of ``duration``.
label: an optional label for the box.
annotations: any :class:`.Annotation`\\ s to apply to the box. In cases where order
is important, annotations are to be interpreted in the same order they appear in
the iterable.
"""
self._circuit = circuit
self._duration = duration
Expand Down
1 change: 1 addition & 0 deletions qiskit/circuit/controlflow/switch_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
cases: an ordered iterable of the corresponding value of the ``target`` and the circuit
block that should be executed if this is matched. There is no fall-through between
blocks, and the order matters.
label: An optional label for identifying the instruction.
"""

from qiskit.circuit import QuantumCircuit
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def convert_durations_to_dt(qc: QuantumCircuit, dt_in_sec: float, inplace=True):

Returns a new circuit if `inplace=False`.

Parameters:
Args:
qc (QuantumCircuit): Duration of dt in seconds used for conversion.
dt_in_sec (float): Duration of dt in seconds used for conversion.
inplace (bool): All durations are converted inplace or return new circuit.
Expand Down
3 changes: 3 additions & 0 deletions qiskit/circuit/library/arithmetic/adders/adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self, num_state_qubits: int, label: str | None = None) -> None:
Args:
num_state_qubits: The number of qubits in each of the registers.
name: The name of the circuit.
label: An optional label for identifying the instruction.
"""
if num_state_qubits < 1:
raise ValueError("Need at least 1 state qubit.")
Expand Down Expand Up @@ -155,6 +156,7 @@ def __init__(self, num_state_qubits: int, label: str | None = None) -> None:
Args:
num_state_qubits: The number of qubits in each of the registers.
name: The name of the circuit.
label: An optional label for identifying the instruction.
"""
if num_state_qubits < 1:
raise ValueError("Need at least 1 state qubit.")
Expand Down Expand Up @@ -211,6 +213,7 @@ def __init__(self, num_state_qubits: int, label: str | None = None) -> None:
Args:
num_state_qubits: The number of qubits in each of the registers.
name: The name of the circuit.
label: An optional label for identifying the instruction.
"""
if num_state_qubits < 1:
raise ValueError("Need at least 1 state qubit.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def slope(self, slope: float) -> None:
"""Set the multiplicative factor of the rotation angles.

Args:
The slope of the rotation angles.
slope: The slope of the rotation angles.
"""
if self._slope is None or slope != self._slope:
self._invalidate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __init__(
num_result_qubits: The number of result qubits to limit the output to.
Default value is ``2 * num_state_qubits`` to represent any possible
result from the multiplication of the two inputs.
name: The name of the circuit.
label: The optional string label to apply to the instruction.
Raises:
ValueError: If ``num_state_qubits`` is smaller than 1.
ValueError: If ``num_result_qubits`` is smaller than ``num_state_qubits``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def coeffs(self, coeffs: list[float]) -> None:
``coeffs[i]`` is the coefficient of the i-th power of x.

Args:
The coefficients of the polynomial.
coeffs: The coefficients of the polynomial.
"""
self._invalidate()
self._coeffs = coeffs
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def num_qubits(self, num_qubits: int) -> None:
"""Set the number of qubits for the n-local circuit.

Args:
The new number of qubits.
num_qubits: The new number of qubits.
"""
if self._num_qubits != num_qubits:
# invalidate the circuit
Expand Down Expand Up @@ -666,7 +666,7 @@ def ordered_parameters(self, parameters: ParameterVector | list[Parameter]) -> N
"""Set the parameters used in the underlying circuit.

Args:
The parameters to be used in the underlying circuit.
parameters: The parameters to be used in the underlying circuit.

Raises:
ValueError: If the length of ordered parameters does not match the number of
Expand Down
5 changes: 4 additions & 1 deletion qiskit/circuit/library/standard_gates/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,15 +1243,18 @@ def __init__(
):
"""
Args:
num_ctrl_qubits: Number of controls to add. Defaults to ``1``.
dirty_ancillas: when set to ``True``, the method applies an optimized multicontrolled-X gate
up to a relative phase using dirty ancillary qubits with the properties of lemmas 7 and 8
from arXiv:1501.06911, with at most 8*k - 6 CNOT gates.
For k within the range {1, ..., ceil(n/2)}. And for n representing the total number of
qubits.
label: Optional gate label. Defaults to ``None``.
ctrl_state: The control state of the gate, specified either as an integer or a bitstring
(e.g. ``"110"``). If ``None``, defaults to the all-ones state ``2**num_ctrl_qubits - 1``
relative_phase: when set to ``True``, the method applies the optimized multicontrolled-X gate
up to a relative phase, in a way that, by lemma 7 of arXiv:1501.06911, the relative
phases of the ``action part`` cancel out with the phases of the ``reset part``.

action_only: when set to ``True``, the method applies only the action part of lemma 8
from arXiv:1501.06911.

Expand Down
10 changes: 7 additions & 3 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5857,7 +5857,8 @@ def ecr(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet:
For the full matrix form of this gate, see the underlying gate documentation.

Args:
qubit1, qubit2: The qubits to apply the gate to.
qubit1: The first qubit to apply the gate to.
qubit2: The second qubit to apply the gate to.

Returns:
A handle to the instructions created.
Expand Down Expand Up @@ -5970,7 +5971,8 @@ def swap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet
For the full matrix form of this gate, see the underlying gate documentation.

Args:
qubit1, qubit2: The qubits to apply the gate to.
qubit1: The first qubit to apply the gate to.
qubit2: The second qubit to apply the gate to.

Returns:
A handle to the instructions created.
Expand All @@ -5987,7 +5989,8 @@ def iswap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSe
For the full matrix form of this gate, see the underlying gate documentation.

Args:
qubit1, qubit2: The qubits to apply the gate to.
qubit1: The first qubit to apply the gate to.
qubit2: The second qubit to apply the gate to.

Returns:
A handle to the instructions created.
Expand Down Expand Up @@ -6914,6 +6917,7 @@ def _push_scope(
Args:
qubits: Any qubits that this scope should automatically use.
clbits: Any clbits that this scope should automatically use.
registers: Any registers that this scope should automatically use.
allow_jumps: Whether this scope allows jumps to be used within it.
forbidden_message: If given, all attempts to add instructions to this scope will raise a
:exc:`.CircuitError` with this message.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/dagcircuit/dagdependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def global_phase(self, angle: float | ParameterExpression):
"""Set the global phase of the circuit.

Args:
angle (float, ParameterExpression)
angle (float, ParameterExpression): The angle to set the global phase to.
"""
from qiskit.circuit.parameterexpression import ParameterExpression # needed?

Expand Down
2 changes: 1 addition & 1 deletion qiskit/dagcircuit/dagdependency_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def global_phase(self, angle):
"""Set the global phase of the circuit.

Args:
angle (float, ParameterExpression)
angle (float, ParameterExpression): The angle to set the global phase to.
"""
if isinstance(angle, ParameterExpression):
self._global_phase = angle
Expand Down
8 changes: 8 additions & 0 deletions qiskit/passmanager/passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _passmanager_frontend(

Args:
input_program: Input program.
**kwargs: Keyword arguments for the pass manager frontend.

Returns:
Pass manager IR.
Expand All @@ -162,6 +163,7 @@ def _passmanager_backend(
in_program: The input program, this can be used if you need
any metadata about the original input for the output.
It should not be mutated.
**kwargs: Keyword arguments for the pass manager backend.

Returns:
Output program.
Expand Down Expand Up @@ -290,6 +292,8 @@ def _run_workflow(
Args:
program: Arbitrary program to optimize.
pass_manager: Pass manager with scheduled passes.
initial_property_set: An optional dictionary to preseed the
property set in the pass manager with.
**kwargs: Keyword arguments for IR conversion.

Returns:
Expand Down Expand Up @@ -342,6 +346,10 @@ def _run_workflow_in_new_process(
Args:
program: Arbitrary program to optimize.
pass_manager_bin: Binary of the pass manager with scheduled passes.
initial_property_set: An optional dictionary to preseed the
property set in the pass manager with.
callback: An optional callable that will be called after each pass
executes.

Returns:
Optimized program.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/primitives/containers/bindings_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def as_array(self, parameters: Iterable[ParameterLike] | None = None) -> np.ndar

The parameters are indexed along the last dimension of the returned array.

Parameters:
Args:
parameters: Optional parameters that determine the order of the output.

Returns:
Expand Down
2 changes: 2 additions & 0 deletions qiskit/primitives/primitive_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def __init__(self, function, *args, **kwargs):
"""
Args:
function: A callable function to execute the job.
args: any additional positional arguments
kwargs: any additional keyword arguments
"""
super().__init__(str(uuid.uuid4()))
self._future = None
Expand Down
2 changes: 1 addition & 1 deletion qiskit/primitives/statevector_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _samples_to_packed_array(
def _final_measurement_mapping(circuit: QuantumCircuit) -> dict[tuple[ClassicalRegister, int], int]:
"""Return the final measurement mapping for the circuit.

Parameters:
Args:
circuit: Input quantum circuit.
Comment on lines -257 to 258
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind standardising these, but Napoleon documents "Args" as an alias to "Parameters", so they should be all internally normalised into the same section heading anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was a bit annoying, but the rule checker only looks for Args it doesn't know about Parameters. I assume it's because the rule documents itself as only working with Google style docs.


Returns:
Expand Down
2 changes: 2 additions & 0 deletions qiskit/qasm3/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def __init__(
default. While the output of this printer is always unambiguous, using ``else``
without immediately opening an explicit scope with ``{ }`` in nested contexts can
cause issues, in the general case, which is why it is sometimes less supported.
experimental: any experimental features to enable during the export. See
:class:`ExperimentalFeatures` for more details.
"""
self.stream = stream
self.indent = indent
Expand Down
4 changes: 2 additions & 2 deletions qiskit/quantum_info/analysis/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def hellinger_distance(dist_p: dict, dist_q: dict) -> float:
"""Computes the Hellinger distance between
two counts distributions.

Parameters:
Args:
dist_p (dict): First dict of counts.
dist_q (dict): Second dict of counts.

Expand Down Expand Up @@ -65,7 +65,7 @@ def hellinger_fidelity(dist_p: dict, dist_q: dict) -> float:
:math:`F(Q,P)=\\left(\\sum_{i}\\sqrt{p_{i}q_{i}}\\right)^{2}` that in turn
is equal to the quantum state fidelity for diagonal density matrices.

Parameters:
Args:
dist_p (dict): First dict of counts.
dist_q (dict): Second dict of counts.

Expand Down
2 changes: 1 addition & 1 deletion qiskit/result/distributions/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, data, shots=None):
def binary_probabilities(self, num_bits=None):
"""Build a probabilities dictionary with binary string keys

Parameters:
Args:
num_bits (int): number of bits in the binary bitstrings (leading
zeros will be padded). If None, a default value will be used.
If keys are given as integers or strings with binary or hex prefix,
Expand Down
6 changes: 3 additions & 3 deletions qiskit/result/distributions/quasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, data, shots=None, stddev_upper_bound=None):
and the parameter ``ndigits`` can be manipulated with the
class attribute ``__ndigits__``. The default is ``15``.

Parameters:
Args:
data (dict): Input quasiprobability data. Where the keys
represent a measured classical value and the value is a
float for the quasiprobability of that result.
Expand Down Expand Up @@ -90,7 +90,7 @@ def nearest_probability_distribution(self, return_distance=False):
it to the closest probability distribution as defined by
the L2-norm.

Parameters:
Args:
return_distance (bool): Return the L2 distance between distributions.

Returns:
Expand Down Expand Up @@ -121,7 +121,7 @@ def nearest_probability_distribution(self, return_distance=False):
def binary_probabilities(self, num_bits=None):
"""Build a quasi-probabilities dictionary with binary string keys

Parameters:
Args:
num_bits (int): number of bits in the binary bitstrings (leading
zeros will be padded). If None, a default value will be used.
If keys are given as integers or strings with binary or hex prefix,
Expand Down
2 changes: 1 addition & 1 deletion qiskit/result/sampled_expval.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def sampled_expectation_value(

Note that passing a raw dict requires bit-string keys.

Parameters:
Args:
dist: Input sampled distribution.
oper: The operator for the observable.

Expand Down
2 changes: 1 addition & 1 deletion qiskit/synthesis/two_qubit/two_qubit_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __init__(self, rxx_equivalent_gate: type[Gate], euler_basis: str = "ZXZ"):
self.scale = self._inner_decomposer.scale
self.euler_basis = euler_basis

def __call__(
def __call__( # noqa: D417 TODO: Add support for the undocumented arguments
Comment thread
Cryoris marked this conversation as resolved.
self, unitary: Operator | np.ndarray, approximate=False, use_dag=False, *, atol=DEFAULT_ATOL
) -> QuantumCircuit:
"""Returns the Weyl decomposition in circuit form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def is_permutation(x: np.ndarray) -> bool:
Checks if array is really an index permutation.

Args:
1D-array of integers that supposedly represents a permutation.
x: 1D-array of integers that supposedly represents a permutation.

Returns:
True, if array is really a permutation of indices.
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/basis/unroll_custom_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def __init__(self, equivalence_library, basis_gates=None, target=None, min_qubit
Ignored if ``target`` is also specified.
target (Optional[Target]): The :class:`~.Target` object corresponding to the compilation
target. When specified, any argument specified for ``basis_gates`` is ignored.
min_qubits (int): The minimum number of qubits for operations in the input
dag to translate.
min_qubits (int): The minimum number of qubits for operations in the input
dag to translate.
"""

super().__init__()
Expand Down
4 changes: 4 additions & 0 deletions qiskit/transpiler/passes/layout/dense_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def _best_subset(self, num_qubits, num_meas, num_cx, coupling_map):

Args:
num_qubits (int): Number of subset qubits to consider.
num_meas (int): The number of measure measurement operations in the circuit.
num_cx (int): The number of CXGates that are in the circuit
coupling_map (CouplingMap): The coupling map representing the connectivity of
the QPU.

Returns:
ndarray: Array of qubits to use for best connectivity mapping.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def _position_in_cmap(self, dag: DAGCircuit, j: int, k: int, layout: Layout) ->
"""A helper function to track the movement of virtual qubits through the swaps.

Args:
dag: The dag the pass is being run on.
j: The index of decision variable j (i.e. virtual qubit).
k: The index of decision variable k (i.e. virtual qubit).
layout: The current layout that takes into account previous swap gates.
Expand Down Expand Up @@ -377,6 +378,7 @@ def _check_edges(self, dag: DAGCircuit, node: DAGOpNode, swap_strategy: SwapStra
"""Check if the swap strategy can create the required connectivity.

Args:
dag: The dag to check edges from.
node: The dag node for which to check if the swap strategy provides enough connectivity.
swap_strategy: The swap strategy that is being used.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run(self, dag: DAGCircuit) -> DAGCircuit:
"""Check for :class:`.PauliEvolutionGate` objects where the summands all commute.

Args:
The DAG circuit in which to look for the commuting evolutions.
dag: The DAG circuit in which to look for the commuting evolutions.

Returns:
The dag in which :class:`.PauliEvolutionGate` objects made of commuting two-qubit Paulis
Expand Down
3 changes: 3 additions & 0 deletions qiskit/transpiler/passes/scheduling/padding/base_padding.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def __init__(
target: The :class:`~.Target` representing the target backend.
If it supplied and it does not support delay instruction on a qubit,
padding passes do not pad any idle time of the qubit.
durations: The instruction durations. This is mostly for legacy applications without
a :class:`.Target`. The ``target`` argument should typically be used instead of
this and if both are specified ``target`` will supersede this argument.
"""
super().__init__()
self.target = target
Expand Down
Loading
Loading