# Single qubit serializers and deserializers # ############################################# # # Single qubit serializers for arbitrary rotations # SINGLE_QUBIT_SERIALIZERS = [ op_serializer.GateOpSerializer( gate_type=ops.PhasedXPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg( serialized_name='axis_half_turns', serialized_type=float, op_getter='phase_exponent', ), op_serializer.SerializingArg( serialized_name='half_turns', serialized_type=float, op_getter='exponent', ), ], ), op_serializer.GateOpSerializer( gate_type=ops.XPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg( serialized_name='axis_half_turns', serialized_type=float, op_getter=lambda op: 0.0,
def _near_mod_2(e, t, atol=1e-8): if isinstance(e, sympy.Symbol): return False return abs((e - t + 1) % 2 - 1) <= atol """Single qubit serializers for arbitrary rotations""" SINGLE_QUBIT_SERIALIZERS = [ op_serializer.GateOpSerializer( gate_type=ops.PhasedXPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg(serialized_name='axis_half_turns', serialized_type=float, gate_getter='phase_exponent'), op_serializer.SerializingArg(serialized_name='half_turns', serialized_type=float, gate_getter='exponent'), ]), op_serializer.GateOpSerializer( gate_type=ops.XPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg(serialized_name='axis_half_turns', serialized_type=float, gate_getter=lambda x: 0.0), op_serializer.SerializingArg(serialized_name='half_turns', serialized_type=float, gate_getter='exponent'),
############################################# # # Single qubit serializers and deserializers # ############################################# # # Single qubit serializers for arbitrary rotations # SINGLE_QUBIT_SERIALIZERS = [ op_serializer.GateOpSerializer( gate_type=ops.PhasedXPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg(serialized_name='axis_half_turns', serialized_type=float, gate_getter='phase_exponent'), op_serializer.SerializingArg(serialized_name='half_turns', serialized_type=float, gate_getter='exponent'), ]), op_serializer.GateOpSerializer( gate_type=ops.XPowGate, serialized_gate_id='xy', args=[ op_serializer.SerializingArg(serialized_name='axis_half_turns', serialized_type=float, gate_getter=lambda x: 0.0), op_serializer.SerializingArg(serialized_name='half_turns', serialized_type=float, gate_getter='exponent'),
from typing import cast, List from cirq import ops, protocols from cirq.google import op_serializer, op_deserializer, serializable_gate_set # The xmon gate set. XMON = serializable_gate_set.SerializableGateSet( gate_set_name='xmon', serializers=[ op_serializer.GateOpSerializer( gate_type=ops.PhasedXPowGate, serialized_gate_id='exp_w', args=[ op_serializer.SerializingArg(serialized_name='axis_half_turns', serialized_type=float, gate_getter='phase_exponent'), op_serializer.SerializingArg(serialized_name='half_turns', serialized_type=float, gate_getter='exponent') ]), op_serializer.GateOpSerializer(gate_type=ops.ZPowGate, serialized_gate_id='exp_z', args=[ op_serializer.SerializingArg( serialized_name='half_turns', serialized_type=float, gate_getter='exponent') ]), op_serializer.GateOpSerializer( gate_type=ops.XPowGate,