23.11.2011 15:01, Fabrice Silva kirjoitti:
Hi folks,
how should I specify a PEP3118 buffer format that could be understand by
numpy as the following dtype:
dtype = [('t11', '|f8'), ('t22', '|f8'), ('t33', '|f8'),
('t23', '|f8'), ('t13', '|f8'), ('t12', '|f8')]
so that I can manipulate a structured array and its fields ?
I tried strings like
T{d:t11: d:t22: d:t33: d:t23: d:t13: d:t12:}:Tensor2d:
d:t11: d:t22: d:t33: d:t23: d:t13: d:t12:
without success
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')])
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion