[Numpy-tickets] [NumPy] #334: Inconsistency in dtypes with scalar shape

NumPy numpy-tickets at scipy.net
Wed Oct 11 11:56:30 CDT 2006


#334: Inconsistency in dtypes with scalar shape
--------------------+-------------------------------------------------------
 Reporter:  faltet  |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:          
Component:  Other   |     Version:  devel   
 Severity:  normal  |    Keywords:          
--------------------+-------------------------------------------------------
 Hi,

 Is the next expected?

 {{{
 In [226]:numpy.dtype(('i4', ()))
 Out[226]:dtype(('int32',()))
 In [227]:numpy.dtype('i4')
 Out[227]:dtype('int32')
 In [230]:numpy.dtype(('i4', ())).type
 Out[230]:<type 'numpy.void'>
 In [231]:numpy.dtype('i4').type
 Out[231]:<type 'numpy.int32'>

 }}}

 in other words, why this difference between numpy.dtype(('i4', ())) and
 numpy.dtype('i4')?. I'd say that it is artificiuos, as per:

 {{{
 In [228]:numpy.dtype('i4').shape
 Out[228]:()
 In [229]:numpy.dtype(('i4', ())).shape
 Out[229]:()
 In [232]:numpy.array([0], numpy.dtype('i4'))
 Out[232]:array([0])
 In [233]:numpy.array([0], numpy.dtype(('i4', ())))
 Out[233]:array([0])
 In [234]:numpy.array([0], numpy.dtype('i4')) == numpy.array([0],
 numpy.dtype(('i4', ())))
 Out[234]:array([True], dtype=bool)

 }}}

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


More information about the Numpy-tickets mailing list