From 75794cbb0024bb4fc45dc164fc859a7834775090 Mon Sep 17 00:00:00 2001 From: Cheng Xing Date: Mon, 13 Jun 2022 12:55:41 -0700 Subject: [PATCH] Update error message when invalid sympy arg is serialized (#5487) Fixes #2384 Clarifies what sympy expressions are allowed when a user tries to serialize a circuit which contains unrecognized Sympy expressions. @dstrain115 --- cirq-google/cirq_google/serialization/arg_func_langs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cirq-google/cirq_google/serialization/arg_func_langs.py b/cirq-google/cirq_google/serialization/arg_func_langs.py index 5d52387aea9..e545f07f830 100644 --- a/cirq-google/cirq_google/serialization/arg_func_langs.py +++ b/cirq-google/cirq_google/serialization/arg_func_langs.py @@ -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(