On Thu, May 20, 2010 at 4:19 PM, <josef.p...@gmail.com> wrote: > On Thu, May 20, 2010 at 4:04 PM, Keith Goodman <kwgood...@gmail.com> 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') > > you're on a 64bit machine? > > S8 is the same size as the float
not float, it should be int, here is float on my Win32: >>> np.array(np.array([1., 2, 3]), dtype=str) array(['1.0', '2.0', '3.0'], dtype='|S8') >>> np.array([8.]).itemsize 8 > > >>>> np.array([8]).itemsize > 4 >>>> np.array(np.array([1, 2, 3]), dtype=str) > array(['1', '2', '3'], > dtype='|S4') >>>> np.array([8]).view(dtype='S4') > array(['\x08'], > dtype='|S4') >>>> np.array([8]).view(dtype='S1') > array(['\x08', '', '', ''], > dtype='|S1') > > But I don't know whether this is a desired feature, numpy might reuse > the existing buffer (?) > > Josef > > >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion