Type annotations of arbitrary SymPy expressions
We currently support explicitly typing symbols (TypedSymbol
) but any other expression can not be typed.
Furthermore, expressions can be cast to a different type (CastFunc
).
These tools are too limited in certain circumstances.
For example consider the SymPy expression CastFunc(expr(4, 2))
and assume that expr
is some expression which does not evaluate directly to a bare constant (this special case is addressed in !411 (merged)).
Because the cast removes all surrounding typing information and the argument does not contain any type hints, we can not infer the types of the constants.
This in turn leads to errors during kernel generation (all constants must be typed).
I suggest generalizing the TypedSymbol
concept to allow annotating arbitrary expressions with type hints.
The class should be as transparent to SymPy as possible, such that SymPy's automatic and explicit transformations are not influenced.
These type annotations are not necessary in most circumstances but in some cases are apparently needed.