Skip to content

Commit b1c6d72

Browse files
dstrain115CirqBot
authored andcommitted
Move SycamoreGate to cirq.google (#2452)
- This gate is hardware-specific, so moving it to cirq.google.
1 parent e05f868 commit b1c6d72

File tree

9 files changed

+35
-18
lines changed

9 files changed

+35
-18
lines changed

cirq/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@
240240
SingleQubitMatrixGate,
241241
SWAP,
242242
SwapPowGate,
243-
SYC,
244-
SycamoreGate,
245243
T,
246244
ThreeQubitGate,
247245
ThreeQubitDiagonalGate,

cirq/google/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
LinePlacementStrategy,
6262
)
6363

64+
from cirq.google.ops.sycamore_gate import (
65+
SycamoreGate,
66+
SYC,
67+
)
68+
6469
from cirq.google.optimizers import (
6570
ConvertToXmonGates,
6671
optimized_for_xmon,

cirq/google/gate_sets_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def test_serialize_deserialize_syc():
602602

603603
q0 = cirq.GridQubit(1, 2)
604604
q1 = cirq.GridQubit(1, 3)
605-
op = cirq.SYC(q0, q1)
605+
op = cg.SYC(q0, q1)
606606
assert cg.SYC_GATESET.serialize_op_dict(op) == proto_dict
607607
assert cg.SYC_GATESET.deserialize_op_dict(proto_dict) == op
608608

cirq/google/ops/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2019 The Cirq Developers
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+
# https://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.
14+
15+
from cirq.google.ops.sycamore_gate import (
16+
SycamoreGate,
17+
SYC,
18+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self):
4444
super().__init__(theta=np.pi / 2, phi=np.pi / 6)
4545

4646
def __repr__(self) -> str:
47-
return 'cirq.SYC'
47+
return 'cirq.google.SYC'
4848

4949
def __str__(self) -> str:
5050
return 'SYC'
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
import pytest
1616

1717
import cirq
18+
import cirq.google as cg
1819

1920

2021
@pytest.mark.parametrize('gate_type,qubit_count', (
21-
(cirq.SYC, 2),
22+
(cg.SYC, 2),
2223
(cirq.PhasedXPowGate(phase_exponent=0.1), 1),
2324
(cirq.PhasedXPowGate(exponent=0.5, phase_exponent=0.1), 1),
2425
))
@@ -32,13 +33,13 @@ def test_consistent_protocols(gate_type, qubit_count):
3233

3334

3435
def test_syc_str_repr():
35-
assert str(cirq.SYC) == 'SYC'
36-
assert repr(cirq.SYC) == 'cirq.SYC'
36+
assert str(cg.SYC) == 'SYC'
37+
assert repr(cg.SYC) == 'cirq.google.SYC'
3738

3839

3940
def test_syc_circuit_diagram():
4041
a, b = cirq.LineQubit.range(2)
41-
circuit = cirq.Circuit.from_ops(cirq.SYC(a, b))
42+
circuit = cirq.Circuit.from_ops(cg.SYC(a, b))
4243
cirq.testing.assert_has_diagram(circuit, """
4344
0: ───SYC───
4445
@@ -47,12 +48,12 @@ def test_syc_circuit_diagram():
4748

4849

4950
def test_syc_is_specific_fsim():
50-
assert cirq.SYC == cirq.FSimGate(theta=np.pi / 2, phi=np.pi / 6)
51+
assert cg.SYC == cirq.FSimGate(theta=np.pi / 2, phi=np.pi / 6)
5152

5253

5354
def test_syc_unitary():
5455
cirq.testing.assert_allclose_up_to_global_phase(
55-
cirq.unitary(cirq.SYC),
56+
cirq.unitary(cg.SYC),
5657
np.array([
5758
[1, 0, 0, 0],
5859
[0, 0, -1j, 0],

cirq/ops/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@
203203
SwapPowGate,
204204
)
205205

206-
from cirq.ops.sycamore_gate import (
207-
SycamoreGate,
208-
SYC,
209-
)
210-
211206
from cirq.ops.three_qubit_gates import (
212207
CCNOT,
213208
CCX,

cirq/protocols/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def cirq_class_resolver_dictionary(self) -> Dict[str, Type]:
103103
'SingleQubitPauliStringGateOperation':
104104
cirq.SingleQubitPauliStringGateOperation,
105105
'SwapPowGate': cirq.SwapPowGate,
106-
'SycamoreGate': cirq.SycamoreGate,
106+
'SycamoreGate': cirq.google.SycamoreGate,
107107
'sympy.Symbol': sympy.Symbol,
108108
'sympy.Add': lambda args: sympy.Add(*args),
109109
'sympy.Mul': lambda args: sympy.Mul(*args),

cirq/protocols/json_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ def test_fail_to_resolve():
279279
cirq.X(Q0),
280280
'SwapPowGate': [cirq.SwapPowGate(), cirq.SWAP**0.5],
281281
'SYC':
282-
cirq.SYC,
282+
cirq.google.SYC,
283283
'SycamoreGate':
284-
cirq.SycamoreGate(),
284+
cirq.google.SycamoreGate(),
285285
'T':
286286
cirq.T,
287287
'TOFFOLI':

0 commit comments

Comments
 (0)