Пример #1
0
 def to_proto(self,
              out: operations_pb2.Qubit = None) -> operations_pb2.Qubit:
     """Return the proto form, mutating supplied form if supplied."""
     if out is None:
         out = operations_pb2.Qubit()
     out.row = self.row
     out.col = self.col
     return out
Пример #2
0
def test_to_proto():
    q = XmonQubit(5, 6)

    # Create a new message.
    proto = q.to_proto()
    assert proto.row == 5
    assert proto.col == 6

    # Populate an existing message.
    proto2 = operations_pb2.Qubit()
    q.to_proto(proto2)
    assert proto2.row == 5
    assert proto2.col == 6
Пример #3
0
    v = cirq.google.JobConfig(project_id='my-project-id',
                              program_id='my-program-id',
                              job_id='my-job-id')

    assert repr(v) == ("JobConfig(project_id='my-project-id', "
                       "program_id='my-program-id', "
                       "job_id='my-job-id', gcs_prefix=None, "
                       "gcs_program=None, gcs_results=None)")


_A_RESULT = program_pb2.Result(sweep_results=[
    program_pb2.SweepResult(
        repetitions=1,
        measurement_keys=[
            program_pb2.MeasurementKey(
                key='q', qubits=[operations_pb2.Qubit(row=1, col=1)])
        ],
        parameterized_results=[
            program_pb2.ParameterizedResult(params=params_pb2.ParameterDict(
                assignments={'a': 1}),
                                            measurement_results=b'01')
        ])
])

_RESULTS = program_pb2.Result(sweep_results=[
    program_pb2.SweepResult(
        repetitions=1,
        measurement_keys=[
            program_pb2.MeasurementKey(
                key='q', qubits=[operations_pb2.Qubit(row=1, col=1)])
        ],