[SciPy-dev] Unexpected behavior getting fields from a structured array
by Skipper Seabold other posts by this author
Nov 6 2009 4:26PM messages near this date
Re: [SciPy-dev] Cython and large generated .c files
|
[SciPy-dev] Build failure on OS X 10.5.8, Python 2.5, gcc-4.0.1
All,
I just got bit by this and was curious if this is just a limitation of
structured arrays.
import numpy as np
dt = [('var1', 'f'),('var2','f'),('var3','f')]
a = np.array([(1,3.5,0),(1,2.5,1),(3,4,1)], dtype=dt)
a[['var2','var3','var1']].view('f').reshape(3,3)
Out[100]:
array([[ 1. , 3.5, 0. ],
[ 1. , 2.5, 1. ],
[ 3. , 4. , 1. ]], dtype=float32)
I expected this to give me the fields in the order I asked for them,
but I got the fields in the order they occur. Based on recent
discussions I guess this makes sense, so this might just be something
to look out for?
Skipper
_______________________________________________
Scipy-dev mailing list
Scipy-dev@[...].org
http://mail.scipy.org/mailman/listinfo/scipy-dev
|