|
From: Francesc A. <fa...@ca...> - 2006-02-01 16:37:20
|
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 =3D numpy.ones((3,3),dtype=3Dnumpy.int32) > > In [8]: a.dtype.name > -------------------------------------------------------------------------= =2D- > 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, =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" Index: numpy/core/src/arrayobject.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- 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) { =2D int len; =2D PyTypeObject *typeobj =3D self->typeobj; + int len; + char *w_unders; + PyTypeObject *typeobj =3D self->typeobj; PyObject *res; =20 =2D /* Both are equivalents, but second is more resistent to changes */ =2D/* len =3D strlen(typeobj->tp_name) - 8; */ =2D if (PyTypeNum_ISUSERDEF(self->type_num)) { res =3D PyString_FromString(typeobj->tp_name); } else { =2D len =3D strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name); + w_unders =3D strchr(typeobj->tp_name, (int)'_'); + if (w_unders !=3D NULL) + len =3D w_unders-(typeobj->tp_name); + else + /* '_' not found! returning the complete name! */ + len =3D strlen(typeobj->tp_name); res =3D PyString_FromStringAndSize(typeobj->tp_name, len); } if (PyTypeNum_ISEXTENDED(self->type_num) && self->elsize !=3D 0) { |