20 May
2010
20 May
'10
10:28 p.m.
Thu, 20 May 2010 13:04:11 -0700, Keith Goodman wrote:
Why do the follow expressions give different dtype?
np.array([1, 2, 3], dtype=str) array(['1', '2', '3'], dtype='|S1') np.array(np.array([1, 2, 3]), dtype=str) array(['1', '2', '3'], dtype='|S8')
Scalars seem to be handled specially. Anyway, automatic determination of the string size is a bit dangerous to rely on with non-strings in the array:
np.array([np.array(12345)], dtype=str) array(['1234'], dtype='|S4')
When I looked at this the last time, it wasn't completely obvious how to make this to do something more sensible. -- Pauli Virtanen