uniqc.circuit_builder.parameter module#

Symbolic parameters for parametric quantum circuits.

This module provides: - Parameter: Named symbolic parameter for parametric gates - Parameters: Array of named parameters with indexing support

These classes enable symbolic expressions for gate parameters that can be bound to concrete values at execution time.

Example usage:

theta = Parameter("theta")
phi = Parameter("phi")

# Arithmetic operations create symbolic expressions
expr = theta + phi / 2

# Bind values and evaluate
theta.bind(1.0)
phi.bind(2.0)
result = expr.evalf()  # 2.0
class uniqc.circuit_builder.parameter.Parameter(name)[source]#

Bases: object

Named symbolic parameter for parametric quantum circuits.

Parameter supports arithmetic operations that create symbolic expressions using sympy. The parameter can be bound to a concrete value or evaluated with a provided values dictionary.

Variables:
  • name – Parameter name

  • symbol – Underlying sympy Symbol

Parameters:

name (str)

Example

>>> theta = Parameter("theta")
>>> phi = Parameter("phi")
>>> expr = theta * 2 + phi
>>> # Evaluate with concrete values
>>> float(expr.subs({theta.symbol: 1.0, phi.symbol: 0.5}))
2.5
bind(value)[source]#

Bind a concrete value to this parameter.

Parameters:

value (float) – The numeric value to bind

Return type:

None

evaluate(values=None)[source]#

Evaluate the parameter.

If the parameter is bound, returns the bound value. Otherwise, looks up the value in the provided dictionary.

Parameters:

values (dict[str, float] | None) – Optional dictionary mapping parameter names to values

Returns:

The evaluated numeric value

Raises:

ValueError – If parameter is not bound and not in values dict

Return type:

float

property is_bound: bool#

Check if the parameter has a bound value.

property name: str#
property symbol: Symbol#
class uniqc.circuit_builder.parameter.Parameters(name, size)[source]#

Bases: object

Array of named parameters with indexing support.

Creates multiple Parameter objects with names “{name}_{index}”.

Variables:

name – Base name for the parameter array

Parameters:

Example

>>> alphas = Parameters("alpha", size=4)
>>> alphas[0]
Parameter('alpha_0')
>>> alphas.names
['alpha_0', 'alpha_1', 'alpha_2', 'alpha_3']
>>> alphas.bind([0.1, 0.2, 0.3, 0.4])
>>> alphas[0].evaluate()
0.1
bind(values)[source]#

Bind values to all parameters.

Parameters:

values (list[float]) – List of values (must match array size)

Raises:

ValueError – If values length doesn’t match array size

Return type:

None

evaluate(values=None)[source]#

Evaluate all parameters.

Parameters:

values (list[float] | None) – Optional list of values to use (must match array size)

Returns:

List of evaluated values

Return type:

list[float]

property name: str#
property names: list[str]#

Return list of all parameter names.

property symbols: list[Symbol]#

Return list of all sympy symbols.