This is a general problem in trying to use JSON to send arbitrary python objects. Its not made for that purpose, JSON itself only supports a very limited grammar (only one sequence type for instance, as you noticed), so in general you will need to specify your own encoding/decoding for more complex objects you want to send over JSON.
In the case of an object dtype, dtypestr = str(dtype) gives you a nice JSONable string representation, which you can convert back into a dtype using np.dtype(eval(dtypestr)) On Sat, Dec 13, 2014 at 9:25 AM, Sebastian <se...@sebix.at> wrote: > > 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 > > > _______________________________________________ > 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