2010/1/1 Ernest Adrogué <[email protected]>: > Hi, > > I find myself doing this: > > In [244]: x > Out[244]: > array([[0, 1, 2], > [3, 4, 5], > [6, 7, 8]]) > > In [245]: y=x.copy() > > In [251]: y.dtype.char > Out[251]: 'l' > > In [252]: dt=np.dtype([('a','l'),('b','l'),('c','l')]) > > In [254]: y.dtype=dt > > Is it okay? > The problem is that it's not easy to rebuild the array. > I tried with: > > y.astype(dt) > np.array(y, dt) > np.array(y.tolist(), dt) > > None worked.
y.view(dt) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
