cirq_google.serializable_gate_set.SerializableGateSet

A class for serializing and deserializing programs and operations.

This class is for cirq_google.api.v2. protos.

gate_set_name The name used to identify the gate set.
serializers The GateOpSerializers to use for serialization. Multiple serializers for a given gate type are allowed and will be checked for a given type in the order specified here. This allows for a given gate type to be serialized into different serialized form depending on the parameters of the gate.
deserializers The GateOpDeserializers to convert serialized forms of gates to GateOperations.

Methods

deserialize

View source

Deserialize a Circuit from a cirq_google.api.v2.Program.

Args
proto A dictionary representing a cirq_google.api.v2.Program proto.
device If the proto is for a schedule, a device is required Otherwise optional.

Returns
The deserialized Circuit, with a device if device was not None.

deserialize_op

View source

Deserialize an Operation from a cirq_google.api.v2.Operation.

Args
operation_proto A dictionary representing a cirq_google.api.v2.Operation proto.

Returns
The deserialized Operation.

is_supported

View source

Whether the given object contains only supported operations.

is_supported_operation

View source

Whether or not the given gate can be serialized by this gate set.

serialize

View source

Serialize a Circuit to cirq_google.api.v2.Program proto.

Args
program The Circuit to serialize.

serialize_op

View source

Serialize an Operation to cirq_google.api.v2.Operation proto.

Args
op The operation to serialize.

Returns
A dictionary corresponds to the cirq_google.api.v2.Operation proto.

supported_gate_types

View source

with_added_gates

View source

Creates a new gateset with additional (de)serializers.

Args
gate_set_name Optional new name of the gateset. If not given, use the same name as this gateset.
serializers Serializers to add to those in this gateset.
deserializers Deserializers to add to those in this gateset.