On Wed, Dec 10, 2014 at 8:26 PM, Valentin Haenel <valen...@haenel.co> wrote: > Hi, > > I am using numpy version 1.9.0 and Python 2.7.9 and have a question > about the dtype: > > In [14]: np.dtype("<f8") > Out[14]: dtype('float64') > > In [15]: np.dtype(u"<f8") > Out[15]: dtype('float64') > > In [16]: np.dtype([("<f8", "<f8")]) > Out[16]: dtype([('<f8', '<f8')]) > > So far so good. Now what happens if I use unicode? > > In [17]: np.dtype([(u"<f8", "<f8")]) > --------------------------------------------------------------------------- > TypeError Traceback (most recent call > last) > <ipython-input-17-ce004acab7f5> in <module>() > ----> 1 np.dtype([(u"<f8", "<f8")]) > > TypeError: data type not understood
Yep, looks like a bug to me. (I guess this is particularly relevant when __future__.unicode_literals is in effect.) > Also, it really does need to be a tuple? > > In [18]: np.dtype([["<f8", "<f8"]]) > --------------------------------------------------------------------------- > TypeError Traceback (most recent call > last) > <ipython-input-18-c82761d7306d> in <module>() > ----> 1 np.dtype([["<f8", "<f8"]]) > > TypeError: data type not understood Lists and tuples are both valid inputs to np.dtype, but they're interpreted differently -- the problem here isn't that you used a list, it's that if you use a list then numpy expects different contents. See: http://docs.scipy.org/doc/numpy/user/basics.rec.html -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion