qml.estimator.resource_operator.GateCount

class GateCount(gate, count=1)[source]

Bases: object

A class to represent a gate and its number of occurrences in a circuit or decomposition.

Parameters:
  • gate (CompressedResourceOp) – The compressed resource representation of the gate being counted.

  • counts (int | None) – The number of occurrences of the quantum gate in the circuit or decomposition. Defaults to 1.

Returns:

The container object holding both pieces of information.

Return type:

GateCount

Example

This example creates an object to count 5 instances of qre.QFT acting on three wires:

>>> from pennylane import estimator as qre
>>> qft = qre.resource_rep(qre.QFT, {"num_wires": 3})
>>> counts = qre.GateCount(qft, 5)
>>> counts
(5 x QFT(3))