Skip to content

Commit

Permalink
Update error message when invalid sympy arg is serialized (#5487)
Browse files Browse the repository at this point in the history
Fixes #2384

Clarifies what sympy expressions are allowed when a user tries to serialize a circuit which contains unrecognized Sympy expressions.

@dstrain115
  • Loading branch information
verult authored Jun 13, 2022
1 parent c313868 commit 75794cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cirq-google/cirq_google/serialization/arg_func_langs.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ def check_support(func_type: str) -> str:
for arg in value.args:
arg_to_proto(arg, arg_function_language=arg_function_language, out=msg.func.args.add())
else:
raise ValueError(f'Unrecognized arg type: {type(value)}')
raise ValueError(
f"Unrecognized Sympy expression type: {type(value)}."
" Only the following types are recognized: 'sympy.Symbol', 'sympy.Add', 'sympy.Mul',"
" 'sympy.Pow'."
)


def float_arg_from_proto(
Expand Down

0 comments on commit 75794cb

Please sign in to comment.