3.3. qupulse.expressions¶
This module defines the class Expression to represent mathematical expression as well as corresponding exception classes.
-
class
qupulse.expressions.
Expression
(*args, **kwargs)[source]¶ Bases:
qupulse.serialization.AnonymousSerializable
Base class for expressions.
-
evaluate_in_scope
(scope)[source]¶ Evaluate the expression by taking the variables from the given scope (typically of type Scope but it can be any mapping.) :type scope:
Mapping
:param scope:Returns:
-
classmethod
make
(expression_or_dict, numpy_evaluation=None)[source]¶ Backward compatible expression generation
- Return type
Union
[ExpressionScalar
,ExpressionVector
, ~_ExpressionType]
-
-
exception
qupulse.expressions.
ExpressionVariableMissingException
(variable, expression)[source]¶ Bases:
Exception
An exception indicating that a variable value was not provided during expression evaluation.
See also
qupulse.expressions.Expression
-
class
qupulse.expressions.
ExpressionScalar
(ex)[source]¶ Bases:
qupulse.expressions.Expression
A scalar mathematical expression instantiated from a string representation. TODO: update doc! TODO: write tests!
Create an Expression object.
Receives the mathematical expression which shall be represented by the object as a string which will be parsed using py_expression_eval. For available operators, functions and constants see SymPy documentation
- Parameters
ex (string) – The mathematical expression represented as a string
-
__init__
(ex)[source]¶ Create an Expression object.
Receives the mathematical expression which shall be represented by the object as a string which will be parsed using py_expression_eval. For available operators, functions and constants see SymPy documentation
- Parameters
ex (string) – The mathematical expression represented as a string
- Return type
None
-
get_serialization_data
()[source]¶ Return all data relevant for serialization as a JSON compatible type that is accepted as constructor argument
-
property
sympified_expression
¶ - Return type
Expr
-
property
underlying_expression
¶ - Return type
Expr
-
class
qupulse.expressions.
ExpressionVector
(expression_vector)[source]¶ Bases:
qupulse.expressions.Expression
N-dimensional expression. TODO: write doc! TODO: write tests!
-
get_serialization_data
()[source]¶ Return all data relevant for serialization as a JSON compatible type that is accepted as constructor argument
-
sympify_vector
= <numpy.vectorize object>¶
-