Im having a little trouble creating a numpy array with a specific
dtype. I can create the array b with dtype=int, but not with the dtype
I want. Any idea what I am doing wrong here?
In [450]: import numpy as np
In [451]: print np.__version__
1.2.0.dev5243
In [452]: dtype=np.dtype([('spam', '<i4',1),('ham', '<i4',1)] )
In [453]: data = [ [1,2], [3,4], [5,6] ]
In [454]: b = np.array( data, dtype=dtype)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/titan/sameer/tmp/test.py
----> 1
2
3
4
5
TypeError: expected a readable buffer object
In [455]: b = np.array( data, dtype=int)
In [456]: print b
[[1 2]
[3 4]
[5 6]]
Thanks.
Sameer
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion