forked from M-Labs/artiq
1
0
Fork 0

compiler: Add ndarray .shape access

This commit is contained in:
David Nadlinger 2020-07-25 22:58:42 +01:00
parent 40f59561f2
commit 632c5bc937
2 changed files with 4 additions and 1 deletions

View File

@ -881,7 +881,7 @@ class LLVMIRGenerator:
if types.is_tuple(typ):
return self.llbuilder.extract_value(self.map(insn.object()), attr,
name=insn.name)
elif not builtins.is_allocated(typ):
elif builtins.is_array(typ) or not builtins.is_allocated(typ):
return self.llbuilder.extract_value(self.map(insn.object()),
self.attr_index(typ, attr),
name=insn.name)

View File

@ -3,6 +3,7 @@
ary = array([1, 2, 3])
assert len(ary) == 3
assert ary.shape == [3]
# FIXME: Implement ndarray indexing
# assert [x*x for x in ary] == [1, 4, 9]
@ -10,6 +11,8 @@ assert len(ary) == 3
empty_array = array([1])
empty_array = array([])
assert len(empty_array) == 0
assert empty_array.shape == [0]
matrix = array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
assert len(matrix) == 2
assert matrix.shape == [2, 3]