[Scipy-svn] r7120 - trunk/scipy/ndimage/src
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Feb 2 12:47:11 EST 2011
Author: charris
Date: 2011-02-02 11:47:10 -0600 (Wed, 02 Feb 2011)
New Revision: 7120
Modified:
trunk/scipy/ndimage/src/ni_support.c
Log:
BUG: Fix ndimage type checks, part of ticket #1724.
Modified: trunk/scipy/ndimage/src/ni_support.c
===================================================================
--- trunk/scipy/ndimage/src/ni_support.c 2011-02-02 05:06:44 UTC (rev 7119)
+++ trunk/scipy/ndimage/src/ni_support.c 2011-02-02 17:47:10 UTC (rev 7120)
@@ -119,6 +119,41 @@
return 1;
}
+/* Some NumPy types are ambiguous */
+int NI_CanonicalType(int type_num)
+{
+ switch (type_num) {
+ case NPY_INT:
+ return NPY_INT32;
+
+ case NPY_LONG:
+#if NPY_SIZEOF_LONG == 4
+ return NPY_INT32;
+#else
+ return NPY_INT64;
+#endif
+
+ case NPY_LONGLONG:
+ return NPY_INT64;
+
+ case NPY_UINT:
+ return NPY_UINT32;
+
+ case NPY_ULONG:
+#if NPY_SIZEOF_LONG == 4
+ return NPY_UINT32;
+#else
+ return NPY_UINT64;
+#endif
+
+ case NPY_ULONGLONG:
+ return NPY_UINT64;
+
+ default:
+ return type_num;
+ }
+}
+
/* Initialize a line buffer */
int NI_InitLineBuffer(PyArrayObject *array, int axis, npy_intp size1,
npy_intp size2, npy_intp buffer_lines, double *buffer_data,
@@ -147,7 +182,7 @@
buffer->array_data = (void *)PyArray_DATA(array);
buffer->buffer_data = buffer_data;
buffer->buffer_lines = buffer_lines;
- buffer->array_type = array->descr->type_num;
+ buffer->array_type = NI_CanonicalType(PyArray_DESCR(array)->type_num);
buffer->array_lines = array_lines;
buffer->next_line = 0;
buffer->size1 = size1;
More information about the Scipy-svn
mailing list