File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
cirq-google/cirq_google/serialization Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -750,6 +750,10 @@ def _deserialize_gate_op(
750
750
p = arg_func_langs .float_arg_from_proto (
751
751
operation_proto .noisechannel .depolarizingchannel .probability
752
752
)
753
+ if not isinstance (p , float ):
754
+ raise ValueError (
755
+ f"Depolarizing noise probability { p } " "cannot be symbol or None"
756
+ ) # pragma: nocover
753
757
op = cirq .DepolarizingChannel (p = p )(* qubits )
754
758
elif which_channel_type == 'randomgatechannel' :
755
759
p = arg_func_langs .float_arg_from_proto (
@@ -760,12 +764,16 @@ def _deserialize_gate_op(
760
764
constants = constants ,
761
765
deserialized_constants = deserialized_constants ,
762
766
)
767
+ if sub_gate is None :
768
+ raise ValueError (
769
+ "Not a valid gate for RandomGateChannel: " f"{ operation_proto } "
770
+ ) # pragma: nocover
763
771
op = cirq .RandomGateChannel (probability = p , sub_gate = sub_gate .gate )(* qubits )
764
772
else :
765
773
raise ValueError (
766
774
f'Unsupported serialized noise channel with type "{ which_channel_type } ".'
767
775
f'\n \n operation_proto:\n { operation_proto } '
768
- )
776
+ ) # pragma: nocover
769
777
else :
770
778
raise ValueError (
771
779
f'Unsupported serialized gate with type "{ which_gate_type } ".'
You can’t perform that action at this time.
0 commit comments