Skip to main content
IBM Quantum Platform

ParameterExpressionTable

class samplomatic.samplex.ParameterExpressionTable

GitHub

Bases: object

Evaluates a list of parameter expressions given a list of parameter values.

An instance of this class owns an ordered list of MM ParameterExpressions that together implicitly specify an ordered list of distinct NN Parameters. Because parameter expressions can involve multiple parameters, because distinct parameter expressions can reference the same parameters, and because parameter expressions that are completely bound contain no parameters, there is in general no relationship between NN and MM. However, N=MN=M in the common special case that all parameter expressions are just, in fact, unique parameters.

The evaluate() method accepts NN parameter values, and returns numeric values for each of the MM parameter expressions.

This class can be used as a shim for tools that want to accept parameter values but use expressions of them without the tedious responsibilities usually attached.

Attributes Summary

Column 1
Column 2
num_expressionsThe number of parameter expressions to evaluate; the return size of evaluate().
num_parametersThe number of unique input parameters across all expressions.
parametersThe unique parameters across all expressions in sorted order.

Methods Summary

Column 1
Column 2
append(expression)Add a parameter expression to the table.
evaluate(parameter_values[, indices])Return numeric values for the table's expressions.

Attributes Documentation

num_expressions

The number of parameter expressions to evaluate; the return size of evaluate().

num_parameters

The number of unique input parameters across all expressions.

parameters

The unique parameters across all expressions in sorted order.

The same sorting order as qiskit is used, where ParameterVector elements are arranged numerically, but otherwise alphabetically by name.

Methods Documentation

append

append(expression: ParameterExpression) → int

GitHub

Add a parameter expression to the table.

Parameters

expression – The parameter expression to append.

Returns

The index of the appended expression.

Raises

ParameterError – If the expression contains a parameter that is not already in this table but whose name conflicts with an existing parameter. Keep in mind that Parameters use instance equality.

evaluate

evaluate(parameter_values: Sequence[float] | dict[Parameter, float], indices: Sequence[int] | None = None) → ndarray

GitHub

Return numeric values for the table’s expressions.

Parameters

  • parameter_values – The parameter values, either as a map from parameters to their values, or just the values in parameter-sorted order (see parameters).
  • indices – An optional sequence of expression indices to evaluate. When None, all expressions are evaluated in order. When provided, only the expressions at the given indices are evaluated, in the given order, so len(returned_array) == len(indices).

Returns

An array of evaluated expressions.

Raises

ParameterError – If the correct number of parameters is not supplied, or if some expression requires a value for a parameter that was not provided.

Was this page helpful?
Report a bug, typo, or request content on GitHub.