Coverage for /home/runner/work/tket/tket/pytket/pytket/utils/stats.py: 100%
4 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-14 10:02 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-14 10:02 +0000
1# Copyright Quantinuum
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15from collections import Counter
17from pytket.circuit import Circuit, OpType
20def gate_counts(circ: Circuit) -> Counter[OpType]:
21 """
22 Count the number of gates of each type in a circuit.
24 :param circ: circuit
25 :return: count of gates of each type
26 """
27 return Counter(cmd.op.type for cmd in circ)