[Numpy-svn] r3251 - in trunk/numpy: core/src lib

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Oct 5 00:49:12 CDT 2006


Author: oliphant
Date: 2006-10-05 00:49:08 -0500 (Thu, 05 Oct 2006)
New Revision: 3251

Modified:
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/lib/function_base.py
Log:
Fix up __array_interface__ getting and depth discovery for scalars.

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-10-04 09:49:54 UTC (rev 3250)
+++ trunk/numpy/core/src/arrayobject.c	2006-10-05 05:49:08 UTC (rev 3251)
@@ -6702,7 +6702,8 @@
         }
         if (PyArray_Check(s))
                 return PyArray_NDIM(s);
-        if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))
+        if (PyArray_IsScalar(s, Generic)) return 0;
+        if (PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))
                 return stop_at_string ? 0:1;
         if (stop_at_tuple && PyTuple_Check(s)) return 0;
         if ((e=PyObject_GetAttrString(s, "__array_interface__")) != NULL) {

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-10-04 09:49:54 UTC (rev 3250)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-10-05 05:49:08 UTC (rev 3251)
@@ -749,84 +749,28 @@
 }
 
 static PyObject *
-gentype_typestr_get(PyObject *self)
+gentype_shape_get(PyObject *self)
 {
-        PyArrayObject *arr;
-        PyObject *ret;
-
-        arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
-        ret = PyObject_GetAttrString((PyObject *)arr->descr, "str");
-        Py_DECREF(arr);
-        return ret;
+        return PyTuple_New(0);
 }
 
+
 static PyObject *
-gentype_descr_get(PyObject *self)
+gentype_interface_get(PyObject *self)
 {
         PyArrayObject *arr;
         PyObject *inter;
-        PyObject *ret;
 
         arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
+        if (arr == NULL) return NULL;
         inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__");
         Py_DECREF(arr);
-        if (inter == NULL) return NULL;
-        ret = PyDict_GetItemString(inter, "descr");
-        Py_DECREF(inter);
-        Py_XINCREF(ret);
-        return ret;
+        return inter;
 }
 
-static PyObject *
-gentype_shape_get(PyObject *self)
-{
-        return PyTuple_New(0);
-}
 
-static PyObject *
-gentype_dataptr_get(PyObject *self)
-{
-        return Py_BuildValue("NO",PyString_FromString(""),Py_True);
-}
 
-
 static PyObject *
-gentype_interface_get(PyObject *self)
-{
-        PyObject *obj, *dict;
-        dict = PyDict_New();
-        if (dict == NULL) return NULL;
-        obj = gentype_typestr_get(self);
-        if (obj == NULL) goto fail;
-        PyDict_SetItemString(dict, "typestr", obj);
-        Py_DECREF(obj);
-
-        obj = gentype_shape_get(self);
-        if (obj == NULL) goto fail;
-        PyDict_SetItemString(dict, "shape", obj);
-        PyDict_SetItemString(dict, "strides", obj);
-        Py_DECREF(obj);
-
-        obj = gentype_dataptr_get(self);
-        if (obj == NULL) goto fail;
-        PyDict_SetItemString(dict, "data", obj);
-        Py_DECREF(obj);
-
-        obj = gentype_descr_get(self);
-        if (obj == NULL) goto fail;
-        PyDict_SetItemString(dict, "descr", obj);
-        Py_DECREF(obj);
-
-        return dict;
-
- fail:
-        Py_DECREF(dict);
-        return NULL;
-}
-
-
-
-static PyObject *
 gentype_typedescr_get(PyObject *self)
 {
         return (PyObject *)PyArray_DescrFromScalar(self);

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-10-04 09:49:54 UTC (rev 3250)
+++ trunk/numpy/lib/function_base.py	2006-10-05 05:49:08 UTC (rev 3251)
@@ -1023,8 +1023,7 @@
 
 def kaiser(M,beta):
     """kaiser(M, beta) returns a Kaiser window of length M with shape parameter
-    beta. It depends on numpy.special (in full numpy) for the modified bessel
-    function i0.
+    beta. 
     """
     from numpy.dual import i0
     n = arange(0,M)



More information about the Numpy-svn mailing list