qrisp.QuantumCircuit.count_ops#

QuantumCircuit.count_ops()[source]#

Counts the amount of operations of each kind. Note that operations are identified by their name.

Returns
count_dicdict

A dictionary containing the gate counts.

Examples

We create a QuantumCircuit containing a number of gates and evaluates the gate-counts:

>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(5)
>>> qc.x(qc.qubits)
>>> qc.cx(0, range(1,5))
>>> qc.z(1)
>>> qc.t(range(5))
>>> qc.count_ops()
{'x': 5, 'cx': 4, 'z': 1, 't': 5}