[Numpy-discussion] Question about dtype

Sebastian sebix at sebix.at
Sat Dec 13 03:25:13 EST 2014


Hi,

I'll just comment on the creation of your dtype:

> dt = [("<f8", "<f8")]

You are creating a dtype with one field called '<f8' and with type '<f8':

>>> dt = [("<f8", "<f8")]
>>> dty = np.dtype(dt)
>>> dty.names

('<f8',)

What you may want are two fields with type '<f8' and without fieldname:

>>> dt = [("<f8", "<f8")]
>>> dty = np.dtype(('<f8,<f8'))
>>> dty.names

('f0', 'f1')
>>> dty.descr

[('f0', '<f8'), ('f1', '<f8')]

I can't help you with the json-module and what it's doing there. As the
output is unequal to the input, I suspect JSON to be misbehaving here.
If you need to store the dtype as strings, not as binary pickle, you can
use pickle.dumps and pickle.loads





More information about the NumPy-Discussion mailing list