lpython
lpython copied to clipboard
Implement numpy.size() and numpy.shape()
And use the ArraySize intrinsic.
Also shape()
Next on my TODO list (after https://github.com/lfortran/lfortran/issues/1210).
numpy.size() has already been completed in this #1777 .
Also
shape()
I can try to add this. But for shape we would need another intrinsic like ArrayShape right?
Use the Shape IntrinsicArrayFunction. Here is how LFortran does it:
integer(8) :: x(2, 2)
print*, shape(x)
end
It gives:
[(Print
[(IntrinsicArrayFunction
Shape
[(ArrayPhysicalCast
(Var 2 x)
FixedSizeArray
DescriptorArray
(Array
(Integer 8)
[((IntegerConstant 1 (Integer 4))
(IntegerConstant 2 (Integer 4)))
((IntegerConstant 1 (Integer 4))
(IntegerConstant 2 (Integer 4)))]
DescriptorArray
)
()
)]
0
(Array
(Integer 4)
[((IntegerConstant 1 (Integer 4))
(IntegerConstant 2 (Integer 4)))]
FixedSizeArray
)
(ArrayConstant
[(IntegerConstant 2 (Integer 4))
(IntegerConstant 2 (Integer 4))]
(Array
(Integer 4)
[((IntegerConstant 1 (Integer 4))
(IntegerConstant 2 (Integer 4)))]
FixedSizeArray
)
ColMajor
)
)]
()
()
)]