Skip to content

Commit

Permalink
Add back modifiers in front of signatures (#1337)
Browse files Browse the repository at this point in the history
Part of  #1287

This PR adds modifiers to the signatures of our API components. We
continue removing the modifiers for attributes and properties given that
we don't show their signature on the website.

This change should be merged after changing the MDX components on IQP to
support the new prop.
  • Loading branch information
arnaucasau authored May 13, 2024
1 parent 8b3432a commit bb39ba7
Show file tree
Hide file tree
Showing 471 changed files with 696 additions and 672 deletions.
2 changes: 1 addition & 1 deletion docs/api/qiskit/circuit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Almost all circuit functions and methods will raise a [`CircuitError`](#qiskit.c

#### CircuitError

<Class id="qiskit.circuit.CircuitError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/exceptions.py#L18-L19" signature="qiskit.circuit.CircuitError(*message)">
<Class id="qiskit.circuit.CircuitError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/exceptions.py#L18-L19" signature="qiskit.circuit.CircuitError(*message)" modifiers="exception">
Base class for errors raised while processing a circuit.

Set the error message.
Expand Down
28 changes: 14 additions & 14 deletions docs/api/qiskit/circuit_classical.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The expression system is based on tree representation. All nodes in the tree are

#### Expr

<Class id="qiskit.circuit.classical.expr.Expr" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L47-L79" signature="qiskit.circuit.classical.expr.Expr">
<Class id="qiskit.circuit.classical.expr.Expr" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L47-L79" signature="qiskit.circuit.classical.expr.Expr" modifiers="class">
Root base class of all nodes in the expression tree. The base case should never be instantiated directly.

This must not be subclassed by users; subclasses form the internal data of the representation of expressions, and it does not make sense to add more outside of Qiskit library code.
Expand All @@ -64,7 +64,7 @@ The entry point from general circuit objects to the expression system is by wrap

#### Var

<Class id="qiskit.circuit.classical.expr.Var" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L109-L168" signature="final class qiskit.circuit.classical.expr.Var(var, type)">
<Class id="qiskit.circuit.classical.expr.Var" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L109-L168" signature="qiskit.circuit.classical.expr.Var(var, type)" modifiers="final class">
A classical variable.

Variables are immutable after construction, so they can be used as dictionary keys.
Expand All @@ -74,15 +74,15 @@ Similarly, literals used in comparison (such as integers) should be lifted to [`

#### Value

<Class id="qiskit.circuit.classical.expr.Value" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L171-L188" signature="final class qiskit.circuit.classical.expr.Value(value, type)">
<Class id="qiskit.circuit.classical.expr.Value" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L171-L188" signature="qiskit.circuit.classical.expr.Value(value, type)" modifiers="final class">
A single scalar value.
</Class>

The operations traditionally associated with pre-, post- or infix operators in programming are represented by the [`Unary`](#qiskit.circuit.classical.expr.Unary "qiskit.circuit.classical.expr.Unary") and [`Binary`](#qiskit.circuit.classical.expr.Binary "qiskit.circuit.classical.expr.Binary") nodes as appropriate. These each take an operation type code, which are exposed as enumerations inside each class as [`Unary.Op`](#qiskit.circuit.classical.expr.Unary.Op "qiskit.circuit.classical.expr.Unary.Op") and [`Binary.Op`](#qiskit.circuit.classical.expr.Binary.Op "qiskit.circuit.classical.expr.Binary.Op") respectively.

#### Unary

<Class id="qiskit.circuit.classical.expr.Unary" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L191-L244" signature="final class qiskit.circuit.classical.expr.Unary(op, operand, type)">
<Class id="qiskit.circuit.classical.expr.Unary" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L191-L244" signature="qiskit.circuit.classical.expr.Unary(op, operand, type)" modifiers="final class">
A unary expression.

**Parameters**
Expand All @@ -93,7 +93,7 @@ The operations traditionally associated with pre-, post- or infix operators in p

##### Op

<Class id="qiskit.circuit.classical.expr.Unary.Op" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L203-L225" signature="Op(value)">
<Class id="qiskit.circuit.classical.expr.Unary.Op" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L203-L225" signature="Op(value)" modifiers="class">
Enumeration of the opcodes for unary operations.

The bitwise negation [`BIT_NOT`](#qiskit.circuit.classical.expr.Unary.Op.BIT_NOT "qiskit.circuit.classical.expr.Unary.Op.BIT_NOT") takes a single bit or an unsigned integer of known width, and returns a value of the same type.
Expand All @@ -116,7 +116,7 @@ The operations traditionally associated with pre-, post- or infix operators in p

#### Binary

<Class id="qiskit.circuit.classical.expr.Binary" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L247-L327" signature="final class qiskit.circuit.classical.expr.Binary(op, left, right, type)">
<Class id="qiskit.circuit.classical.expr.Binary" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L247-L327" signature="qiskit.circuit.classical.expr.Binary(op, left, right, type)" modifiers="final class">
A binary expression.

**Parameters**
Expand All @@ -128,7 +128,7 @@ The operations traditionally associated with pre-, post- or infix operators in p

##### Op

<Class id="qiskit.circuit.classical.expr.Binary.Op" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L260-L306" signature="Op(value)">
<Class id="qiskit.circuit.classical.expr.Binary.Op" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L260-L306" signature="Op(value)" modifiers="class">
Enumeration of the opcodes for binary operations.

The bitwise operations [`BIT_AND`](#qiskit.circuit.classical.expr.Binary.Op.BIT_AND "qiskit.circuit.classical.expr.Binary.Op.BIT_AND"), [`BIT_OR`](#qiskit.circuit.classical.expr.Binary.Op.BIT_OR "qiskit.circuit.classical.expr.Binary.Op.BIT_OR") and [`BIT_XOR`](#qiskit.circuit.classical.expr.Binary.Op.BIT_XOR "qiskit.circuit.classical.expr.Binary.Op.BIT_XOR") apply to two operands of the same type, which must be a single bit or an unsigned integer of fixed width. The resultant type is the same as the two input types.
Expand Down Expand Up @@ -211,7 +211,7 @@ Expressions in this system are defined to act only on certain sets of types. How

#### Cast

<Class id="qiskit.circuit.classical.expr.Cast" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L82-L106" signature="final class qiskit.circuit.classical.expr.Cast(operand, type, implicit=False)">
<Class id="qiskit.circuit.classical.expr.Cast" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/expr.py#L82-L106" signature="qiskit.circuit.classical.expr.Cast(operand, type, implicit=False)" modifiers="final class">
A cast from one type to another, implied by the use of an expression in a different context.
</Class>

Expand Down Expand Up @@ -592,7 +592,7 @@ A typical consumer of the expression tree wants to recursively walk through the

#### ExprVisitor

<Class id="qiskit.circuit.classical.expr.ExprVisitor" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/visitors.py#L30-L56" signature="qiskit.circuit.classical.expr.ExprVisitor">
<Class id="qiskit.circuit.classical.expr.ExprVisitor" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/expr/visitors.py#L30-L56" signature="qiskit.circuit.classical.expr.ExprVisitor" modifiers="class">
Base class for visitors to the [`Expr`](#qiskit.circuit.classical.expr.Expr "qiskit.circuit.classical.expr.Expr") tree. Subclasses should override whichever of the `visit_*` methods that they are able to handle, and should be organised such that non-existent methods will never be called.

##### visit\_binary
Expand Down Expand Up @@ -741,7 +741,7 @@ All types inherit from an abstract base class:

#### Type

<Class id="qiskit.circuit.classical.types.Type" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L49-L80" signature="qiskit.circuit.classical.types.Type">
<Class id="qiskit.circuit.classical.types.Type" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L49-L80" signature="qiskit.circuit.classical.types.Type" modifiers="class">
Root base class of all nodes in the type tree. The base case should never be instantiated directly.

This must not be subclassed by users; subclasses form the internal data of the representation of expressions, and it does not make sense to add more outside of Qiskit library code.
Expand All @@ -753,13 +753,13 @@ The two different types available are for Booleans (corresponding to [`Clbit`](q

#### Bool

<Class id="qiskit.circuit.classical.types.Bool" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L83-L96" signature="final class qiskit.circuit.classical.types.Bool">
<Class id="qiskit.circuit.classical.types.Bool" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L83-L96" signature="qiskit.circuit.classical.types.Bool" modifiers="final class">
The Boolean type. This has exactly two values: `True` and `False`.
</Class>

#### Uint

<Class id="qiskit.circuit.classical.types.Uint" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L99-L117" signature="final class qiskit.circuit.classical.types.Uint(width)">
<Class id="qiskit.circuit.classical.types.Uint" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/types.py#L99-L117" signature="qiskit.circuit.classical.types.Uint(width)" modifiers="final class">
An unsigned integer of fixed bit width.
</Class>

Expand Down Expand Up @@ -806,7 +806,7 @@ The return value is an enumeration [`Ordering`](#qiskit.circuit.classical.types.

##### Ordering

<Class id="qiskit.circuit.classical.types.Ordering" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/ordering.py#L38-L55" signature="qiskit.circuit.classical.types.Ordering(value)">
<Class id="qiskit.circuit.classical.types.Ordering" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/ordering.py#L38-L55" signature="qiskit.circuit.classical.types.Ordering(value)" modifiers="class">
Enumeration listing the possible relations between two types. Types only have a partial ordering, so it’s possible for two types to have no sub-typing relationship.

Note that the sub-/supertyping relationship is not the same as whether a type can be explicitly cast from one to another.
Expand Down Expand Up @@ -932,7 +932,7 @@ The return values from this function are an enumeration explaining the types of

##### CastKind

<Class id="qiskit.circuit.classical.types.CastKind" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/ordering.py#L168-L184" signature="qiskit.circuit.classical.types.CastKind(value)">
<Class id="qiskit.circuit.classical.types.CastKind" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/classical/types/ordering.py#L168-L184" signature="qiskit.circuit.classical.types.CastKind(value)" modifiers="class">
A return value indicating the type of cast that can occur from one type to another.
</Class>

8 changes: 4 additions & 4 deletions docs/api/qiskit/circuit_singleton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The public classes correspond to the standard classes [`Instruction`](qiskit.cir

### SingletonInstruction

<Class id="qiskit.circuit.singleton.SingletonInstruction" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L503-L522" signature="qiskit.circuit.singleton.SingletonInstruction(*args, _force_mutable=False, **kwargs)">
<Class id="qiskit.circuit.singleton.SingletonInstruction" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L503-L522" signature="qiskit.circuit.singleton.SingletonInstruction(*args, _force_mutable=False, **kwargs)" modifiers="class">
A base class to use for [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") objects that by default are singleton instances.

This class should be used for instruction classes that have fixed definitions and do not contain any unique state. The canonical example of something like this is [`Measure`](qiskit.circuit.library.Measure "qiskit.circuit.library.Measure") which has an immutable definition and any instance of [`Measure`](qiskit.circuit.library.Measure "qiskit.circuit.library.Measure") is the same. Using singleton instructions as a base class for these types of gate classes provides a large advantage in the memory footprint of multiple instructions.
Expand All @@ -56,15 +56,15 @@ The public classes correspond to the standard classes [`Instruction`](qiskit.cir

### SingletonGate

<Class id="qiskit.circuit.singleton.SingletonGate" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L534-L541" signature="qiskit.circuit.singleton.SingletonGate(*args, _force_mutable=False, **kwargs)">
<Class id="qiskit.circuit.singleton.SingletonGate" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L534-L541" signature="qiskit.circuit.singleton.SingletonGate(*args, _force_mutable=False, **kwargs)" modifiers="class">
A base class to use for [`Gate`](qiskit.circuit.Gate "qiskit.circuit.Gate") objects that by default are singleton instances.

This class is very similar to [`SingletonInstruction`](#qiskit.circuit.singleton.SingletonInstruction "qiskit.circuit.singleton.SingletonInstruction"), except implies unitary [`Gate`](qiskit.circuit.Gate "qiskit.circuit.Gate") semantics as well. The same caveats around setting attributes in that class apply here as well.
</Class>

### SingletonControlledGate

<Class id="qiskit.circuit.singleton.SingletonControlledGate" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L554-L566" signature="qiskit.circuit.singleton.SingletonControlledGate(*args, _force_mutable=False, **kwargs)">
<Class id="qiskit.circuit.singleton.SingletonControlledGate" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L554-L566" signature="qiskit.circuit.singleton.SingletonControlledGate(*args, _force_mutable=False, **kwargs)" modifiers="class">
A base class to use for [`ControlledGate`](qiskit.circuit.ControlledGate "qiskit.circuit.ControlledGate") objects that by default are singleton instances

This class is very similar to [`SingletonInstruction`](#qiskit.circuit.singleton.SingletonInstruction "qiskit.circuit.singleton.SingletonInstruction"), except implies unitary [`ControlledGate`](qiskit.circuit.ControlledGate "qiskit.circuit.ControlledGate") semantics as well. The same caveats around setting attributes in that class apply here as well.
Expand Down Expand Up @@ -126,7 +126,7 @@ Subclasses of [`SingletonInstruction`](#qiskit.circuit.singleton.SingletonInstru

#### \_singleton\_lookup\_key

<Function id="qiskit.circuit.singleton.SingletonInstruction._singleton_lookup_key" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L411-L451" signature="static SingletonInstruction._singleton_lookup_key(*_args, **_kwargs)">
<Function id="qiskit.circuit.singleton.SingletonInstruction._singleton_lookup_key" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/circuit/singleton.py#L411-L451" signature="SingletonInstruction._singleton_lookup_key(*_args, **_kwargs)" modifiers="static">
Given the arguments to the constructor, return a key tuple that identifies the singleton instance to retrieve, or `None` if the arguments imply that a mutable object must be created.

For performance, as a special case, this method will not be called if the class constructor was given zero arguments (e.g. the construction `XGate()` will not call this method, but `XGate(label=None)` will), and the default singleton will immediately be returned.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/qiskit/dagcircuit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ python_api_name: qiskit.dagcircuit

### DAGCircuitError

<Class id="qiskit.dagcircuit.DAGCircuitError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/dagcircuit/exceptions.py#L19-L29" signature="qiskit.dagcircuit.DAGCircuitError(*msg)">
<Class id="qiskit.dagcircuit.DAGCircuitError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/dagcircuit/exceptions.py#L19-L29" signature="qiskit.dagcircuit.DAGCircuitError(*msg)" modifiers="exception">
Base class for errors raised by the DAGCircuit object.

Set the error message.
</Class>

### DAGDependencyError

<Class id="qiskit.dagcircuit.DAGDependencyError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/dagcircuit/exceptions.py#L32-L42" signature="qiskit.dagcircuit.DAGDependencyError(*msg)">
<Class id="qiskit.dagcircuit.DAGDependencyError" github="https://github.com/Qiskit/qiskit/tree/stable/1.0/qiskit/dagcircuit/exceptions.py#L32-L42" signature="qiskit.dagcircuit.DAGDependencyError(*msg)" modifiers="exception">
Base class for errors raised by the DAGDependency object.

Set the error message.
Expand Down
Loading

0 comments on commit bb39ba7

Please sign in to comment.