[Numpy-discussion] Some inconsistency in numarray.records format support

Francesc Altet faltet at carabos.com
Tue Jan 17 08:21:01 CST 2006


Hi,

When building recarrays in numpy following the numarray convention:

In [2]: numpy.zeros((3,), dtype='u1')
Out[2]: array([0, 0, 0], dtype=uint8)

In [3]: numpy.zeros((3,), dtype='u1,f4')
Out[3]: array([(0, 0.0), (0, 0.0), (0, 0.0)], dtype=(void,5))

In [4]: numpy.zeros((3,), dtype='2u1,f4')
Out[4]:
array([(array([0, 0], dtype=uint8), 0.0),
       (array([0, 0], dtype=uint8), 0.0), (array([0, 0], dtype=uint8), 0.0)], 
dtype=(void,6))

In [7]: numpy.zeros((3,), dtype='(2,)u1,f4')
Out[7]:
array([(array([0, 0], dtype=uint8), 0.0),
       (array([0, 0], dtype=uint8), 0.0), (array([0, 0], dtype=uint8), 0.0)], 
dtype=(void,6))


So far so good, but


In [5]: numpy.zeros((3,), dtype='2u1')
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most recent 
call last)

/home/faltet/python.nobackup/numpy/<ipython console>

TypeError: data type not understood

Also:

In [6]: numpy.zeros((3,), dtype='(2,)u1')
---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most recent 
call last)

/home/faltet/python.nobackup/numpy/<ipython console>

/usr/lib/python2.4/site-packages/numpy/core/_internal.py in _commastring(astr)
    296     res = _split(astr)
    297     if (len(res)) == 1:
--> 298         raise ValueError, "no commas present"
    299     result = []
    300     for k,item in enumerate(res):

ValueError: no commas present

Perhaps this is the same case as defining tables with just one column?

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"





More information about the Numpy-discussion mailing list