[NumPy-Tickets] [NumPy] #1758: Assiging to structured array rows with list/array fails
NumPy Trac
numpy-tickets@scipy....
Sun Mar 6 22:04:09 CST 2011
#1758: Assiging to structured array rows with list/array fails
------------------------+---------------------------------------------------
Reporter: rgommers | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.core | Version: devel
Keywords: |
------------------------+---------------------------------------------------
Assigning to a structured array with a tuple works, with a list results in
an error. Would be good if this could be made to work (this is an
enhancement request). With an array gives no warning or exception, but
results in garbage. This is a bug.
See also
http://thread.gmane.org/gmane.comp.python.numeric.general/30793/focus=30793
{{{
>>> arr = np.zeros((5,), dtype=[('var1','f8'),('var2','f8')])
>>> arr['var1'] = np.arange(5)
>>> arr
array([(0.0, 0.0), (1.0, 0.0), (2.0, 0.0), (3.0, 0.0), (4.0, 0.0)],
dtype=[('var1', '<f8'), ('var2', '<f8')])
>>> arr[0] = (10,20)
>>> arr
array([(10.0, 20.0), (1.0, 0.0), (2.0, 0.0), (3.0, 0.0), (4.0, 0.0)],
dtype=[('var1', '<f8'), ('var2', '<f8')])
>>> arr[0] = np.array([10,20])
>>> arr
array([(4.2439915824246103e-313, 0.0), (1.0, 0.0), (2.0, 0.0), (3.0, 0.0),
(4.0, 0.0)],
dtype=[('var1', '<f8'), ('var2', '<f8')])
}}}
If this is fixed, please update doc/structured_arrays.py (section "Filling
structured arrays").
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1758>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list