# [NumPy-Tickets] [NumPy] #1990: Data can be truncated in creation of an array from a mixed sequence of numeric values and strings

NumPy Trac numpy-tickets@scipy....
Mon Dec 5 03:12:21 CST 2011

```#1990: Data can be truncated in creation of an array from a mixed sequence of
numeric values and strings
------------------------+---------------------------------------------------
Reporter:  thouis      |       Owner:  somebody
Type:  defect      |      Status:  new
Priority:  normal      |   Milestone:  1.6.2
Component:  numpy.core  |     Version:  1.6.0
Keywords:              |
------------------------+---------------------------------------------------
When an array is created from a sequence of numeric (boolean, int, float,
complex) and string (bytes, str, unicode) values, the resulting array type
is string, but only the string values are being used to choose the string
length, leading to truncation of data.

Code:
import numpy as np
for numericval in [True, 1234, 123.4, complex(1, 3)]:
for stringconversion in [str, unicode, bytes]:
print repr(np.array([numericval, stringconversion('abc')]))

Result:
array(['Tru', 'abc'],
dtype='|S3')
array([u'Tru', u'abc'],
dtype='<U3')
array(['Tru', 'abc'],
dtype='|S3')
array(['123', 'abc'],
dtype='|S3')
array([u'123', u'abc'],
dtype='<U3')
array(['123', 'abc'],
dtype='|S3')
array(['123', 'abc'],
dtype='|S3')
array([u'123', u'abc'],
dtype='<U3')
array(['123', 'abc'],
dtype='|S3')
array(['(1+', 'abc'],
dtype='|S3')
array([u'(1+', u'abc'],
dtype='<U3')
array(['(1+', 'abc'],
dtype='|S3')

--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1990>
NumPy <http://projects.scipy.org/numpy>
My example project
```