Add dynamic array type
Adds a dynamic type for array symbols (with known shape) such that the dtype
can be inserted later:
TypedSymbol(name, DynamicNumericArrayType(shape))
The typifier (currently) makes no attempt at inferring the shape of untyped array symbols.
Therefore, their shape must be specified explicitly by specifying a type.
Prior to this MR, this had to be a PsArrayType
which requires a concrete scalar type.
I wanted to solve this issue by extending the DaynamicType
enum with a third variant, which takes the shape as a member (using a similar solution as here).
Unfortunately, that is incompatible with SymPy because nested types can not be pickled
Merge request reports
Activity
changed milestone to %Release 2.0
added API Update feature v2.0-dev labels
requested review from @da15siwa
assigned to @he66coqe
The typifier should infer the shape: see here.
Yes, thanks for the hint.
To explain the source of my confusion: When a symbol is used in a
PsSubscript
, then the shape can not be inferred and a concretePsArrayType
must already be known (see here). This is fine if the typifier had previously processed the declaration of that array symbol, and inferred the shape from the RHS. However, it means that one must not typify code containing subscripts before typifying the declaration. This means that one has to be careful about usingFreezeExpressions
vs.AstFactory
.