Re: [Numpy-discussion] Question about dtype

2014-12-13 Thread Sebastian
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


Re: [Numpy-discussion] Question about dtype

2014-12-13 Thread Eelco Hoogendoorn
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


[Numpy-discussion] Bilinear interpolation (numpy only)

2014-12-13 Thread Nicolas P. Rougier

Hi all,

Does anyone has a simple 2D linear interpolation for resizing an image (without 
scipy) ?

Ideally, something like ```def zoom(Z, ratio): ...``` where Z is a 2D scalar 
array and ratio the scaling factor.
(I'm currently using ```scipy.ndimage.interpolation.zoom``` but I would like to 
avoid the scipy dependency)
Thanks.



Nicolas
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion