forked from M-Labs/artiq
compiler: Add ndarray .shape access
This commit is contained in:
parent
40f59561f2
commit
632c5bc937
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue