On Thu, May 20, 2010 at 4:04 PM, Keith Goodman <kwgoodman@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
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