xnd-project / libxnd

Subsumed into xnd
https://xnd.io/
BSD 3-Clause "New" or "Revised" License
80 stars 12 forks source link

Cannot specify type for ragged array #39

Closed acu192 closed 5 years ago

acu192 commented 5 years ago

From the documentation (here), it shows how to specify the type of a fixed array. Here is that example below:

>>> from xnd import xnd
>>>
>>> xnd([[0, 1, 2], [3, 4, 5]])
xnd([[0, 1, 2], [3, 4, 5]], type='2 * 3 * int64')
>>>
>>> xnd([[0, 1, 2], [3, 4, 5]], type='2 * 3 * uint8')
xnd([[0, 1, 2], [3, 4, 5]], type='2 * 3 * uint8')

However, specifying the type is not possible if you are building a ragged array:

>>> from xnd import xnd
>>>
>>> xnd([[0, 1, 2], [3, 4]])
xnd([[0, 1, 2], [3, 4]], type='var * var * int64')
>>>
>>> xnd([[0, 1, 2], [3, 4]], type='var * var * uint8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryan/github/xnd-all/python/xnd/__init__.py", line 127, in __new__
    return super().__new__(cls, type=type, value=value)
ValueError: type must be concrete
skrah commented 5 years ago

Actually it's possible, see here:

https://xnd.readthedocs.io/en/latest/xnd/types.html#id2

acu192 commented 5 years ago

Aww cool. Thank you!