qblox_scheduler.operations.expressions#
Classes that represent expressions, which produce a value when compiled and executed.
Attributes#
Classes#
Data type of a variable or expression. |
|
Expression that produces a value when compiled. |
|
An expression with one operand and one operator. |
|
An expression with two operands and one operator. |
Functions#
|
Make the defined substitutions in the container type val. |
Module Contents#
- class DType[source]#
Bases:
qblox_scheduler.enums.StrEnumData type of a variable or expression.
- AMPLITUDE = 'amplitude'[source]#
An amplitude, corresponding to 0.1, 0.2, 0.3, etc. in dimensionless units ranging from -1 to 1.
- class Expression(dict=None, /, **kwargs)[source]#
Bases:
collections.UserDict,abc.ABCExpression that produces a value when compiled.
- abstract substitute(substitutions: dict[Expression, Expression | int | float | complex]) Expression | int | float | complex[source]#
Substitute matching parts of expression, possibly evaluating a result.
- class UnaryExpression(operator: str, operand: Expression)[source]#
Bases:
ExpressionAn expression with one operand and one operator.
- Parameters:
operator – The operator that acts on the operand.
operand – The expression or variable that is acted on.
- EVALUATORS: ClassVar[dict[str, collections.abc.Callable]][source]#
- property operand: Expression[source]#
The expression or variable that is acted on.
- substitute(substitutions: dict[Expression, Expression | int | float | complex]) Expression | int | float | complex[source]#
Substitute matching operand, possibly evaluating a result.
- reduce() Expression | int | float | complex[source]#
Reduce complex ASTs if they can be simplified due to the presence of constants.
Currently only handles a few cases (
ais a constant value in these examples):-(-expr) -> expr+(expr * a) -> expr * a(same for/)-(expr * a) -> expr * (-a)(same for/)
- Returns:
Expression | int | float | complex The simplified expression.
- class BinaryExpression(lhs: Expression | complex, operator: str, rhs: Expression | complex)[source]#
Bases:
ExpressionAn expression with two operands and one operator.
- Parameters:
lhs – The left-hand side of the expression.
operator – The operator that acts on the operands.
rhs – The right-hand side of the expression.
- EVALUATORS: ClassVar[dict[str, collections.abc.Callable]][source]#
- property lhs: Expression[source]#
The left-hand side of the expression.
- property rhs: Expression | complex[source]#
The right-hand side of the expression.
- substitute(substitutions: dict[Expression, Expression | int | float | complex]) Expression | int | float | complex[source]#
Substitute matching operands, possibly evaluating a result.
- reduce() Expression | int | float | complex[source]#
Reduce complex ASTs if they can be simplified due to the presence of constants.
Currently only handles a few cases (
aandbare constant values in these examples):expr * 1 -> expr(same for/and//)expr + 0 -> expr(same for other applicable operators)(expr * a) * b -> expr * (a * b)(expr * a) / b -> expr * (a / b)(expr / a) * b -> expr * (b / a)(expr / a) / b -> expr / (a * b)(-expr) * b -> expr * (-b)(same for/)
- Returns:
Expression | int | float | complex The simplified expression.
- substitute_value_in_arbitrary_container(val: ContainsExpressionType, substitutions: dict[Expression, Expression | int | float | complex]) tuple[Any, bool][source]#
Make the defined substitutions in the container type val.