Resolves parameters to actual values.

Used in the notebooks

Used in the tutorials

A parameter is a variable whose value has not been determined. A ParamResolver is an object that can be used to assign values for these variables.

ParamResolvers are hashable; their param_dict must not be mutated.

TypeError if formulas are passed as keys.

param_dict A dictionary from the ParameterValue key (str) to its assigned value.



View source

Attempt to resolve a parameter to its assigned value.

Scalars are returned without modification. Strings are resolved via the parameter dictionary with exact match only. Otherwise, strings are considered to be sympy.Symbols with the name as the input string.

A sympy.Symbol is first checked for exact match in the parameter dictionary. Otherwise, it is treated as a sympy.Basic.

A sympy.Basic is resolved using sympy substitution.

Note that passing a formula to this resolver can be slow due to the underlying sympy library. For circuits relying on quick performance, it is recommended that all formulas are flattened before-hand using cirq.flatten or other means so that formula resolution is avoided. If unable to resolve a sympy.Symbol, returns it unchanged. If unable to resolve a name, returns a sympy.Symbol with that name.

value The parameter to try to resolve.
recursive Whether to recursively evaluate formulas.

The value of the parameter as resolved by this resolver.

RecursionError If the ParamResolver detects a loop in recursive resolution.
sympy.SympifyError If the resulting value cannot be interpreted.


View source


View source

Return self==value.


View source


View source


View source

Return self!=value.