Skip to content

Commit 05f51c7

Browse files
change import to cirq_google from cirq.google (#643)
* change import to cirq_google from cirq.google * lint * lint Co-authored-by: MichaelBroughton <[email protected]>
1 parent 41c41e4 commit 05f51c7

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

tensorflow_quantum/core/ops/circuit_execution_ops_test.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from absl.testing import parameterized
2020
from scipy import stats
2121
import cirq
22+
import cirq_google
2223

2324
from tensorflow_quantum.core.ops import batch_util, circuit_execution_ops
2425
from tensorflow_quantum.python import util
@@ -91,9 +92,9 @@ def test_get_expectation_inputs(self):
9192
expected_regex='Sample-based'):
9293
mock_engine = mock.Mock()
9394
circuit_execution_ops.get_expectation_op(
94-
cirq.google.QuantumEngineSampler(engine=mock_engine,
95+
cirq_google.QuantumEngineSampler(engine=mock_engine,
9596
processor_id='test',
96-
gate_set=cirq.google.XMON))
97+
gate_set=cirq_google.XMON))
9798
with self.assertRaisesRegex(
9899
TypeError,
99100
expected_regex="cirq.sim.simulator.SimulatesExpectationValues"):
@@ -112,9 +113,9 @@ def test_get_sampled_expectation_inputs(self):
112113
backend=cirq.DensityMatrixSimulator())
113114
mock_engine = mock.Mock()
114115
circuit_execution_ops.get_sampled_expectation_op(
115-
cirq.google.QuantumEngineSampler(engine=mock_engine,
116+
cirq_google.QuantumEngineSampler(engine=mock_engine,
116117
processor_id='test',
117-
gate_set=cirq.google.XMON))
118+
gate_set=cirq_google.XMON))
118119
with self.assertRaisesRegex(TypeError, expected_regex="a Cirq.Sampler"):
119120
circuit_execution_ops.get_sampled_expectation_op(backend="junk")
120121

@@ -131,9 +132,9 @@ def test_get_samples_inputs(self):
131132
backend=cirq.DensityMatrixSimulator())
132133
mock_engine = mock.Mock()
133134
circuit_execution_ops.get_sampling_op(
134-
backend=cirq.google.QuantumEngineSampler(engine=mock_engine,
135+
backend=cirq_google.QuantumEngineSampler(engine=mock_engine,
135136
processor_id='test',
136-
gate_set=cirq.google.XMON))
137+
gate_set=cirq_google.XMON))
137138
with self.assertRaisesRegex(TypeError,
138139
expected_regex="Expected a Cirq.Sampler"):
139140
circuit_execution_ops.get_sampling_op(backend="junk")
@@ -155,10 +156,10 @@ def test_get_state_inputs(self):
155156
expected_regex="Cirq.SimulatesFinalState"):
156157
mock_engine = mock.Mock()
157158
circuit_execution_ops.get_state_op(
158-
backend=cirq.google.QuantumEngineSampler(
159+
backend=cirq_google.QuantumEngineSampler(
159160
engine=mock_engine,
160161
processor_id='test',
161-
gate_set=cirq.google.XMON))
162+
gate_set=cirq_google.XMON))
162163

163164
with self.assertRaisesRegex(TypeError,
164165
expected_regex="must be type bool."):

tensorflow_quantum/core/ops/cirq_ops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import numpy as np
2020
import tensorflow as tf
2121
import cirq
22+
import cirq_google
2223

2324
from tensorflow_quantum.core.ops import batch_util
2425
from tensorflow_quantum.core.proto import pauli_sum_pb2
@@ -490,7 +491,7 @@ def _no_grad(grad):
490491
]
491492
max_n_qubits = max(len(p.all_qubits()) for p in programs)
492493

493-
if isinstance(sampler, cirq.google.QuantumEngineSampler):
494+
if isinstance(sampler, cirq_google.QuantumEngineSampler):
494495
# group samples from identical circuits to reduce communication
495496
# overhead. Have to keep track of the order in which things came
496497
# in to make sure the output is ordered correctly

tensorflow_quantum/core/ops/cirq_ops_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import tensorflow as tf
1919
from absl.testing import parameterized
2020
import cirq
21+
import cirq_google
2122

2223
from tensorflow_quantum.core.ops import cirq_ops
2324
from tensorflow_quantum.core.serialize import serializer
@@ -342,9 +343,9 @@ def test_get_cirq_sampling_op(self):
342343
cirq_ops._get_cirq_samples(cirq.DensityMatrixSimulator())
343344
mock_engine = mock.Mock()
344345
cirq_ops._get_cirq_samples(
345-
cirq.google.QuantumEngineSampler(engine=mock_engine,
346+
cirq_google.QuantumEngineSampler(engine=mock_engine,
346347
processor_id='test',
347-
gate_set=cirq.google.XMON))
348+
gate_set=cirq_google.XMON))
348349

349350
def test_cirq_sampling_op_inputs(self):
350351
"""test input checking in the cirq sampling op."""

tensorflow_quantum/core/serialize/op_deserializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(self,
209209
self.op_wrapper = op_wrapper
210210

211211
def from_proto(self, proto, *, arg_function_language=''):
212-
"""Turns a cirq.google.api.v2.Operation proto into a GateOperation."""
212+
"""Turns a cirq_google.api.v2.Operation proto into a GateOperation."""
213213
qubits = [qubit_from_proto(q.id) for q in proto.qubits]
214214
args = self._args_from_proto(
215215
proto, arg_function_language=arg_function_language)

tensorflow_quantum/core/serialize/op_serializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def to_proto(
182182
*,
183183
arg_function_language='',
184184
):
185-
"""Returns the cirq.google.api.v2.Operation message as a proto dict."""
185+
"""Returns the cirq_google.api.v2.Operation message as a proto dict."""
186186

187187
gate = op.gate
188188
if not isinstance(gate, self.gate_type):

tensorflow_quantum/core/serialize/serializable_gate_set.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
"""Support for serializing and deserializing cirq.google.api.v2 protos."""
14+
"""Support for serializing and deserializing cirq_google.api.v2 protos."""
1515

1616
import cirq
1717
from tensorflow_quantum.core.proto import program_pb2
@@ -56,7 +56,7 @@ def _function_languages_from_arg(arg_proto):
5656
class SerializableGateSet:
5757
"""A class for serializing and deserializing programs and operations.
5858
59-
This class is for cirq.google.api.v2. protos.
59+
This class is for cirq_google.api.v2. protos.
6060
"""
6161

6262
def __init__(self, gate_set_name, serializers, deserializers):
@@ -118,7 +118,7 @@ def is_supported_operation(self, op):
118118
return False
119119

120120
def serialize(self, program, msg=None, *, arg_function_language=None):
121-
"""Serialize a Circuit to cirq.google.api.v2.Program proto.
121+
"""Serialize a Circuit to cirq_google.api.v2.Program proto.
122122
123123
Args:
124124
program: The Circuit to serialize.
@@ -146,13 +146,13 @@ def serialize_op(
146146
*,
147147
arg_function_language='',
148148
):
149-
"""Serialize an Operation to cirq.google.api.v2.Operation proto.
149+
"""Serialize an Operation to cirq_google.api.v2.Operation proto.
150150
151151
Args:
152152
op: The operation to serialize.
153153
154154
Returns:
155-
A dictionary corresponds to the cirq.google.api.v2.Operation proto.
155+
A dictionary corresponds to the cirq_google.api.v2.Operation proto.
156156
"""
157157
gate_type = type(op.gate)
158158
for gate_type_mro in gate_type.mro():
@@ -169,10 +169,10 @@ def serialize_op(
169169
op, gate_type))
170170

171171
def deserialize(self, proto, device=None):
172-
"""Deserialize a Circuit from a cirq.google.api.v2.Program.
172+
"""Deserialize a Circuit from a cirq_google.api.v2.Program.
173173
174174
Args:
175-
proto: A dictionary representing a cirq.google.api.v2.Program proto.
175+
proto: A dictionary representing a cirq_google.api.v2.Program proto.
176176
device: If the proto is for a schedule, a device is required
177177
Otherwise optional.
178178
@@ -200,11 +200,11 @@ def deserialize_op(
200200
*,
201201
arg_function_language='',
202202
):
203-
"""Deserialize an Operation from a cirq.google.api.v2.Operation.
203+
"""Deserialize an Operation from a cirq_google.api.v2.Operation.
204204
205205
Args:
206206
operation_proto: A dictionary representing a
207-
cirq.google.api.v2.Operation proto.
207+
cirq_google.api.v2.Operation proto.
208208
209209
Returns:
210210
The deserialized Operation.

0 commit comments

Comments
 (0)