[Numpy-discussion] dtype and pep3118

Fabrice Silva silva at lma.cnrs-mrs.fr
Wed Nov 23 10:12:03 EST 2011


Le mercredi 23 novembre 2011 à 15:52 +0100, Pauli Virtanen a écrit :
> 
> >>> dtype = [('t11', '|f8'), ('t22', '|f8'), ('t33', '|f8'),
> ...          ('t23', '|f8'), ('t13', '|f8'), ('t12', '|f8')]
> >>> x = np.zeros([1], dtype=dtype)
> >>> memoryview(x).format
> 'T{d:t11:d:t22:d:t33:d:t23:d:t13:d:t12:}'
> >>> np.array(memoryview(x))
> array([(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
>       dtype=[('t11', '<f8'), ('t22', '<f8'), ('t33', '<f8'), ('t23',
> '<f8'), ('t13', '<f8'), ('t12', '<f8')])

Thanks!

-- 
Fabrice Silva




More information about the NumPy-Discussion mailing list