qp.typing.AbstractWires

class AbstractWires(_num_wires)[source]

Bases: object

An 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 -1 when the wire count is unknown.

dtype

np.int64.

shape

The number of wires expressed as shape (num_wires,).

shape_fixed

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.

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 this AbstractWires.

Parameters:

val (Any) – input value to check for compatibility. This can be another AbstractWires or any object with a length (for example, a Wires instance or a sequence of wire labels).

Returns:

True if val is compatible, False otherwise

Return type:

bool

The following conditions must be met to be considered compatible:

  • If this AbstractWires has 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