cirq.google.GateOpDeserializer

class cirq.google.GateOpDeserializer(serialized_gate_id: str, gate_constructor: Callable, args: Sequence[cirq.google.op_deserializer.DeserializingArg], num_qubits_param: Optional[str] = None, op_wrapper: Callable[[cirq.Operation, cirq.google.api.v2.program_pb2.Operation], cirq.Operation] = <function GateOpDeserializer.<lambda>>)[source]

Describes how to deserialize a proto to a given Gate type.

serialized\_gate\_id

The id used when serializing the gate.

__init__(serialized_gate_id: str, gate_constructor: Callable, args: Sequence[cirq.google.op_deserializer.DeserializingArg], num_qubits_param: Optional[str] = None, op_wrapper: Callable[[cirq.Operation, cirq.google.api.v2.program_pb2.Operation], cirq.Operation] = <function GateOpDeserializer.<lambda>>)[source]

Constructs a deserializer.

Parameters
  • serialized_gate_id – The serialized id of the gate that is being deserialized.

  • gate_constructor – A function that produces the deserialized gate given arguments from args.

  • args – A list of the arguments to be read from the serialized gate and the information required to use this to construct the gate using the gate_constructor above.

  • num_qubits_param – Some gate constructors require that the number of qubits be passed to their constructor. This is the name of the parameter in the constructor for this value. If None, no number of qubits is passed to the constructor.

  • op_wrapper – An optional Callable to modify the resulting GateOperation, for instance, to add tags

Methods

from_proto(proto, *[, arg_function_language])

Turns a cirq.google.api.v2.Operation proto into a GateOperation.