forked from M-Labs/artiq
5ba22c11c3
array([...]), the constructor for NumPy arrays, currently has the status of some weird kind of macro in ARTIQ Python, as it needs to determine the number of dimensions in the resulting array type, which is a fixed type parameter on which inference cannot be performed. This leads to an ambiguity for empty lists, which could contain elements of arbitrary type, including other lists (which would add to the number of dimensions). Previously, I had chosen to make array([]) to be of completely indeterminate type for this reason. However, this is different to how the call behaves in host NumPy, where this is a well-formed call creating an empty 1D array (or 2D for array([[], []]), etc.). This commit adds special matching for (recursive lists of) empty ListT AST nodes to treat them as scalar dimensions, with the element type still unknown. This also happens to fix type inference for embedding empty 1D NumPy arrays from host object attributes, although multi-dimensional arrays will still require work (see GitHub #1633). GitHub: Fixes #1626. |
||
---|---|---|
.. | ||
algorithms | ||
analyses | ||
testbench | ||
transforms | ||
validators | ||
__init__.py | ||
asttyped.py | ||
builtins.py | ||
embedding.py | ||
import_cache.py | ||
iodelay.py | ||
ir.py | ||
math_fns.py | ||
module.py | ||
prelude.py | ||
targets.py | ||
types.py |