-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathalgorithm_summary_test.py
59 lines (55 loc) · 2.09 KB
/
algorithm_summary_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from qualtran.bloqs import basic_gates, mcmt, rotations
from qualtran.resource_counting import GateCounts
from qualtran.surface_code import AlgorithmSummary
@pytest.mark.parametrize(
['bloq', 'summary'],
[
[
basic_gates.TGate(is_adjoint=False),
AlgorithmSummary(n_algo_qubits=1, n_logical_gates=GateCounts(t=1)),
],
[
basic_gates.Toffoli(),
AlgorithmSummary(n_algo_qubits=3, n_logical_gates=GateCounts(toffoli=1)),
],
[
basic_gates.TwoBitCSwap(),
AlgorithmSummary(n_algo_qubits=3, n_logical_gates=GateCounts(cswap=1)),
],
[mcmt.And(), AlgorithmSummary(n_algo_qubits=3, n_logical_gates=GateCounts(and_bloq=1))],
[
basic_gates.ZPowGate(exponent=0.1, eps=1e-11),
AlgorithmSummary(n_algo_qubits=1, n_logical_gates=GateCounts(rotation=1)),
],
[
rotations.phase_gradient.PhaseGradientUnitary(
bitsize=10, exponent=1, is_controlled=False, eps=1e-10
),
AlgorithmSummary(
n_algo_qubits=10, n_logical_gates=GateCounts(clifford=2, t=1, rotation=7)
),
],
[
mcmt.MultiControlX(cvs=(1, 1, 1)),
AlgorithmSummary(
n_algo_qubits=6, n_logical_gates=GateCounts(and_bloq=2, measurement=2, clifford=3)
),
],
],
)
def test_summary_from_bloq(bloq, summary):
assert AlgorithmSummary.from_bloq(bloq) == summary