qp.typing.AbstractWires¶
- class AbstractWires(_num_wires)[source]¶
Bases:
objectAn abstract representation of a sequence of wires that contains the number of wires, useful for resource calculations.
- Parameters:
num_wires (int) – The number of wires. Use
-1when the wire count is unknown.
Attributes
np.int64.
The number of wires expressed as shape
(num_wires,).Whether the number of wires is fixed.
- dtype¶
np.int64. The dtype of wires when used with Catalyst.
- shape¶
The number of wires expressed as shape
(num_wires,).
- shape_fixed¶
Whether the number of wires is fixed.
Methods
is_compatible_with(val)Check whether an input value is compatible with an
AbstractWires.- is_compatible_with(val)[source]¶
Check whether an input value is compatible with an
AbstractWires. A value is considered compatible if it represents a number of wires consistent with thisAbstractWires.- Parameters:
val (Any) – input value to check for compatibility. This can be another
AbstractWiresor any object with a length (for example, aWiresinstance or a sequence of wire labels).- Returns:
Trueifvalis compatible,Falseotherwise- Return type:
bool
The following conditions must be met to be considered compatible:
If this
AbstractWireshas an unknown number of wires (num_wires = -1), then the input value can have any number of wires.Otherwise, the input value must have the same, fixed number of wires.
Example
>>> AbstractWires(-1).is_compatible_with(AbstractWires(3)) True >>> AbstractWires(2).is_compatible_with(AbstractWires(2)) True >>> AbstractWires(2).is_compatible_with(AbstractWires(3)) False >>> AbstractWires(2).is_compatible_with(AbstractWires(-1)) False