[Numpy-discussion] numpy.dtype problem
Francesc Altet
faltet at carabos.com
Wed Feb 1 08:38:01 CST 2006
A Dimecres 01 Febrer 2006 15:46, Christopher Hanley va escriure:
> The following seems to have stopped working:
>
>
> In [6]: import numpy
>
> In [7]: a = numpy.ones((3,3),dtype=numpy.int32)
>
> In [8]: a.dtype.name
> ---------------------------------------------------------------------------
> exceptions.MemoryError Traceback (most
> recent call last)
>
> /data/sparty1/dev/devCode/<console>
>
> MemoryError:
Below is a patch for this. It seems to me that Travis is introducing
new *scalar data types. I'm not sure if they should appear in this
case, but perhaps he can throw some light on this.
Cheers,
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
Index: numpy/core/src/arrayobject.c
===================================================================
--- numpy/core/src/arrayobject.c (revision 2043)
+++ numpy/core/src/arrayobject.c (working copy)
@@ -8132,18 +8132,21 @@
static PyObject *
arraydescr_typename_get(PyArray_Descr *self)
{
- int len;
- PyTypeObject *typeobj = self->typeobj;
+ int len;
+ char *w_unders;
+ PyTypeObject *typeobj = self->typeobj;
PyObject *res;
- /* Both are equivalents, but second is more resistent to changes */
-/* len = strlen(typeobj->tp_name) - 8; */
-
if (PyTypeNum_ISUSERDEF(self->type_num)) {
res = PyString_FromString(typeobj->tp_name);
}
else {
- len = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);
+ w_unders = strchr(typeobj->tp_name, (int)'_');
+ if (w_unders != NULL)
+ len = w_unders-(typeobj->tp_name);
+ else
+ /* '_' not found! returning the complete name! */
+ len = strlen(typeobj->tp_name);
res = PyString_FromStringAndSize(typeobj->tp_name, len);
}
if (PyTypeNum_ISEXTENDED(self->type_num) && self->elsize != 0) {
More information about the Numpy-discussion
mailing list