[Numpy-tickets] [NumPy] #389: ones is not working for compound types

NumPy numpy-tickets at scipy.net
Wed Nov 22 09:53:32 CST 2006


#389: ones is not working for compound types
--------------------+-------------------------------------------------------
 Reporter:  faltet  |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:          
Component:  Other   |     Version:          
 Severity:  normal  |    Keywords:          
--------------------+-------------------------------------------------------
 Hi,

 I don't know if the next is intended or not:

 {{{
 In [51]:numpy.ones(shape=2, dtype='i2')
 Out[51]:array([1, 1], dtype=int16)
 # So far so good. However,
 In [52]:numpy.zeros(shape=2, dtype='i4,i2')
 Out[52]:
 array([(0, 0), (0, 0)],
       dtype=[('f0', '<i4'), ('f1', '<i2')])
 In [53]:numpy.ones(shape=2, dtype='i4,i2')
 ---------------------------------------------------------------------------
 exceptions.TypeError                                 Traceback (most
 recent call last)

 /home/faltet/<ipython console>

 /usr/lib/python2.4/site-packages/numpy/core/numeric.py in ones(shape,
 dtype, order)
     587     """
     588     a = empty(shape, dtype, order)
 --> 589     a.fill(1)
     590     # Above is faster now after addition of fast loops.
     591     #a = zeros(shape, dtype, order)

 TypeError: expected a readable buffer object

 }}}

 I'd say that, provided that ones() works well for single types, and zeros
 also works for compound types, then ones() is having some problem there.

 Using 1.0.1.dev3428

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/389>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list