3.2.2. qupulse.expressions.sympy¶
This module defines the class Expression to represent mathematical expression as well as corresponding exception classes.
Functions
|
|
|
Tries to parse the result as a scalar if possible. |
|
Classes
|
Base class for expressions. |
|
A scalar mathematical expression instantiated from a string representation. |
|
N-dimensional expression. |
|
Metaclass that forwards calls to Expression(...) to Expression.make(...) to make subclass objects |
- class qupulse.expressions.sympy.Expression(*args, **kwargs)[source]¶
Bases:
qupulse.serialization.AnonymousSerializable
Base class for expressions.
- evaluate_in_scope(scope: Mapping) Union[numbers.Number, numpy.ndarray] [source]¶
Evaluate the expression by taking the variables from the given scope (typically of type Scope but it can be any mapping.) :param scope:
Returns:
- evaluate_numeric(**kwargs) Union[numbers.Number, numpy.ndarray] [source]¶
- classmethod make(expression_or_dict, numpy_evaluation=None) Union[qupulse.expressions.sympy.ExpressionScalar, qupulse.expressions.sympy.ExpressionVector, qupulse.expressions.sympy._ExpressionType] [source]¶
Backward compatible expression generation
- property underlying_expression: Union[sympy.core.expr.Expr, numpy.ndarray]¶
- class qupulse.expressions.sympy.ExpressionScalar(*args, **kwargs)[source]¶
Bases:
qupulse.expressions.sympy.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: Union[str, numbers.Number, sympy.core.expr.Expr]) None [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
- evaluate_in_scope(scope: Mapping) Union[numbers.Number, numpy.ndarray] [source]¶
Evaluate the expression by taking the variables from the given scope (typically of type Scope but it can be any mapping.) :param scope:
Returns:
- evaluate_with_exact_rationals(scope: Mapping) Union[numbers.Number, numpy.ndarray] [source]¶
- get_serialization_data() Union[str, float, int] [source]¶
Return all data relevant for serialization as a JSON compatible type that is accepted as constructor argument
- Returns
A JSON compatible type that can be used to construct an equal object.
- property original_expression: Union[str, numbers.Number]¶
- property sympified_expression: sympy.core.expr.Expr¶
- property underlying_expression: sympy.core.expr.Expr¶
- class qupulse.expressions.sympy.ExpressionVector(*args, **kwargs)[source]¶
Bases:
qupulse.expressions.sympy.Expression
N-dimensional expression. TODO: write doc! TODO: write tests!
- evaluate_in_scope(scope: Mapping) numpy.ndarray [source]¶
Evaluate the expression by taking the variables from the given scope (typically of type Scope but it can be any mapping.) :param scope:
Returns:
- get_serialization_data() Sequence[str] [source]¶
Return all data relevant for serialization as a JSON compatible type that is accepted as constructor argument
- Returns
A JSON compatible type that can be used to construct an equal object.
- sympify_vector = <numpy.vectorize object>¶
- to_ndarray() numpy.ndarray [source]¶
- property underlying_expression: numpy.ndarray¶