arrayfire / arrayfire/arrayfire-python

Return fixed length tuple from array.dims()?

Open
#171 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
422
Forks
63
PR merge metrics
No merged PRs in 30d

Description

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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.