autoqasm.operators.assignments module

Operators for assignment statements.

autoqasm.operators.assignments.assign_for_output(target_name: str, value: Any) Any[source]

Operator declares the oq variable, or sets variable’s value if it’s already declared. Runs only for return statements on main decorated functions.

Parameters:
  • target_name (str) – The name of assignment target. It is the variable name on the lhs of an assignment statement.

  • value (Any) – The value of assignment. It is the object on the rhs of an assignment statement.

Returns:

Any – Assignment value with updated name attribute if the value is an oqpy type. Otherwise, it returns unchanged assignment value.

autoqasm.operators.assignments.assign_stmt(target_name: str, value: Any) Any[source]

Operator declares the oq variable, or sets variable’s value if it’s already declared.

Parameters:
  • target_name (str) – The name of assignment target. It is the variable name on the lhs of an assignment statement.

  • value (Any) – The value of assignment. It is the object on the rhs of an assignment statement.

Returns:

Any – Assignment value with updated name attribute if the value is an oqpy type. Otherwise, it returns unchanged assignment value.