[Numpy-discussion] concatenation changes dtype

Travis Oliphant oliphant.travis at ieee.org
Sat Sep 16 17:29:01 CDT 2006


Martin Wiechert wrote:
> Hi list,
>
> Apparently r_[x,x] does not necessarily have the same dtype as x:
>
>   
>>>> from numpy import *
>>>> dt = dtype ([('a', 'b'), ('f4', 'i4')])
>>>> x = zeros ((1,), dt)
>>>> x.dtype
>>>>         
> dtype([('a', '|i1'), ('f4', '<i4')])
>   
>>>> r_[x,x].dtype
>>>>         
> dtype('object')
>   
>>>> import numpy
>>>> numpy.version.version
>>>>         
> '1.0rc1.dev3171'
>
> Does anybody know how to avoid this change of dtype?
>   

Thanks for the check.  It should be fixed now in SVN.  There was an 
inappropriate force to object arrays which neglected this case.

-Travis





More information about the Numpy-discussion mailing list