[NumPy-Tickets] [NumPy] #1612: Alignment don't work in subarrays
NumPy Trac
numpy-tickets@scipy....
Tue Sep 14 10:05:09 CDT 2010
#1612: Alignment don't work in subarrays
---------------------------------------------------+------------------------
Reporter: Ihor.Melnyk | Owner: somebody
Type: defect | Status: new
Priority: highest | Milestone: 2.0.0
Component: numpy.core | Version: devel
Keywords: multiarray alignment padding subarray |
---------------------------------------------------+------------------------
Specifying alignment in dtype specification does not work (alignment
should be 4 in both cases):
{{{
>>> t = np.dtype('1i4', align=True)
>>> t.alignment
4
>>> t = np.dtype('2i4', align=True)
>>> t.alignment
1
}}}
This is critical to ensure that NPY binary data matches exactly complex
structures defined in C.
Proposed solution
{{{
Index: descriptor.c
===================================================================
--- descriptor.c (revision 8715)
+++ descriptor.c (working copy)
@@ -254,6 +254,7 @@
newdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));
newdescr->subarray->base = type;
newdescr->flags = type->flags;
+ newdescr->alignment = type->alignment;
Py_INCREF(val);
newdescr->subarray->shape = val;
Py_XDECREF(newdescr->fields);
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1612>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list