arrayfire-python
arrayfire-python copied to clipboard
Return fixed length tuple from array.dims()?
Hi,
Could you consider changing array.dims() to return a fixed length tuple, like (3,4,1,1)? Currently it's necessary to check the length of the returned tuple before indexing it to get the size of a specific dimension.
>>> import arrayfire as af
>>> aa = af.randu(3,4,1)
>>> aa.dims()
(3, 4)
>>> bb = af.randu(3,4,2)
>>> bb.dims()
(3, 4, 2)
>>>
Something like this...
>>> def dims(arr):
>>> return arr.dims() + ((1,)*(4-len(arr.dims())))
>>> dims(aa)
(3,4,1,1)
@HarryStorbacka a workaround would be af.dim4(*a.shape)