lupinix / rpms / numpy

Forked from rpms/numpy 6 years ago
Clone
e8d5ab0
diff -ur numpy-0.9.8.orig/numpy/core/numeric.py numpy-0.9.8/numpy/core/numeric.py
e8d5ab0
--- numpy-0.9.8.orig/numpy/core/numeric.py	2006-05-17 18:48:38.000000000 -0400
e8d5ab0
+++ numpy-0.9.8/numpy/core/numeric.py	2006-09-05 16:23:00.000000000 -0400
e8d5ab0
@@ -11,6 +11,7 @@
e8d5ab0
            'array2string', 'get_printoptions', 'set_printoptions',
e8d5ab0
            'array_repr', 'array_str', 'set_string_function',
e8d5ab0
            'little_endian',
e8d5ab0
+           'fromiter',
e8d5ab0
            'indices', 'fromfunction',
e8d5ab0
            'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',
e8d5ab0
            'ones', 'identity', 'allclose',
e8d5ab0
@@ -67,6 +68,10 @@
e8d5ab0
 
e8d5ab0
 # end Fernando's utilities
e8d5ab0
 
e8d5ab0
+def fromiter(obj, dtype=None):
e8d5ab0
+    obj = list(obj)
e8d5ab0
+    return array(obj, dtype=dtype)
e8d5ab0
+
e8d5ab0
 def extend_all(module):
e8d5ab0
     adict = {}
e8d5ab0
     for a in __all__:
e8d5ab0
diff -ur numpy-0.9.8.orig/numpy/core/src/arrayobject.c numpy-0.9.8/numpy/core/src/arrayobject.c
e8d5ab0
--- numpy-0.9.8.orig/numpy/core/src/arrayobject.c	2006-05-13 23:42:32.000000000 -0400
e8d5ab0
+++ numpy-0.9.8/numpy/core/src/arrayobject.c	2006-09-05 16:26:47.000000000 -0400
e8d5ab0
@@ -7287,9 +7287,10 @@
e8d5ab0
    adjusted */
e8d5ab0
 
e8d5ab0
 /*OBJECT_API
e8d5ab0
-  Adjusts previously broadcasted iterators so that the largest axis is not iterated 
e8d5ab0
-  over.  Returns dimension which is largest in the range [0,multi->nd).  A -1 
e8d5ab0
-  is returned if multi->nd == 0.
e8d5ab0
+  Adjusts previously broadcasted iterators so that the largest axis
e8d5ab0
+  is not iterated over.
e8d5ab0
+  Returns dimension which is largest in the range [0,multi->nd).
e8d5ab0
+  A -1 is returned if multi->nd == 0.
e8d5ab0
  */
e8d5ab0
 static int
e8d5ab0
 PyArray_RemoveLargest(PyArrayMultiIterObject *multi)
e8d5ab0
diff -ur numpy-0.9.8.orig/numpy/core/src/scalartypes.inc.src numpy-0.9.8/numpy/core/src/scalartypes.inc.src
e8d5ab0
--- numpy-0.9.8.orig/numpy/core/src/scalartypes.inc.src	2006-05-17 14:56:32.000000000 -0400
e8d5ab0
+++ numpy-0.9.8/numpy/core/src/scalartypes.inc.src	2006-09-05 16:28:32.000000000 -0400
e8d5ab0
@@ -1600,12 +1600,15 @@
e8d5ab0
 
e8d5ab0
 /* string and unicode inherit from Python Type first and so GET_ITEM is different to
e8d5ab0
    get to the Python Type.
e8d5ab0
+   ok is a work-around for a bug in complex_new that doesn't allocate
e8d5ab0
+   memory from the sub-types memory allocator.
e8d5ab0
  */
e8d5ab0
 
e8d5ab0
 /**begin repeat 
e8d5ab0
 #name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#
e8d5ab0
 #TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#
e8d5ab0
 #num=1*16,0,0,1#
e8d5ab0
+#ok=0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,1#
e8d5ab0
 */
e8d5ab0
 static PyObject *
e8d5ab0
 @name@_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
e8d5ab0
@@ -1614,6 +1617,7 @@
e8d5ab0
 	PyObject *arr;
e8d5ab0
 	PyArray_Descr *typecode;
e8d5ab0
 
e8d5ab0
+#if @ok@
e8d5ab0
 	if (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) {
e8d5ab0
 		PyTypeObject *sup;
e8d5ab0
 		PyObject *ret;
e8d5ab0
@@ -1625,6 +1629,7 @@
e8d5ab0
 		PyErr_Clear();
e8d5ab0
 		/* now do default conversion */
e8d5ab0
 	}
e8d5ab0
+#endif
e8d5ab0
 
e8d5ab0
 	if (!PyArg_ParseTuple(args, "O", &obj)) return NULL;
e8d5ab0
 
e8d5ab0
diff -ur numpy-0.9.8.orig/numpy/core/tests/test_scalarmath.py numpy-0.9.8/numpy/core/tests/test_scalarmath.py
e8d5ab0
--- numpy-0.9.8.orig/numpy/core/tests/test_scalarmath.py	2006-05-10 18:51:12.000000000 -0400
e8d5ab0
+++ numpy-0.9.8/numpy/core/tests/test_scalarmath.py	2006-09-05 16:28:58.000000000 -0400
e8d5ab0
@@ -11,55 +11,22 @@
e8d5ab0
          N.single, N.double, N.longdouble, N.csingle,
e8d5ab0
          N.cdouble, N.clongdouble]
e8d5ab0
 
e8d5ab0
-# These were generated using old umath
e8d5ab0
-typeconv = array([
e8d5ab0
-    [ 0,  1,  2,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [ 1,  1,  3,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [ 2,  3,  2,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [ 3,  3,  3,  3,  5,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [ 4,  4,  4,  5,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [ 5,  5,  5,  5,  5,  5,  9,  5,  9,  9, 10, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [ 6,  6,  6,  6,  6,  9,  6,  9,  6,  9, 10, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [ 7,  7,  7,  7,  7,  7,  9,  7,  9,  9, 10, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [ 8,  8,  8,  8,  8,  9,  8,  9,  8,  9, 10, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [ 9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 12, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 10, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 11, 12, 13, 14, 15, 16],
e8d5ab0
-    [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 15, 15, 16],
e8d5ab0
-    [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 16, 16],
e8d5ab0
-    [14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 14, 15, 16, 14, 15, 16],
e8d5ab0
-    [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 15, 15, 16],
e8d5ab0
-    [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]
e8d5ab0
-    ])
e8d5ab0
-
e8d5ab0
-typeconv2 = array([
e8d5ab0
-    ['?','b','B','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
e8d5ab0
-    ['b','b','h','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
e8d5ab0
-    ['B','h','B','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
e8d5ab0
-    ['h','h','h','h','i','i','I','i','I','q','Q','f','d','g','F','D','G'],
e8d5ab0
-    ['H','H','H','i','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
e8d5ab0
-    ['i','i','i','i','i','i','q','i','q','q','Q','d','d','g','D','D','G'],
e8d5ab0
-    ['I','I','I','I','I','q','I','q','I','q','Q','d','d','g','D','D','G'],
e8d5ab0
-    ['l','l','l','l','l','l','q','l','q','q','Q','d','d','g','D','D','G'],
e8d5ab0
-    ['L','L','L','L','L','q','L','q','L','q','Q','d','d','g','D','D','G'],
e8d5ab0
-    ['q','q','q','q','q','q','q','q','q','q','d','d','d','g','D','D','G'],
e8d5ab0
-    ['Q','Q','Q','Q','Q','Q','Q','Q','Q','d','Q','d','d','g','D','D','G'],
e8d5ab0
-    ['f','f','f','f','f','d','d','d','d','d','d','f','d','g','F','D','G'],
e8d5ab0
-    ['d','d','d','d','d','d','d','d','d','d','d','d','d','g','D','D','G'],
e8d5ab0
-    ['g','g','g','g','g','g','g','g','g','g','g','g','g','g','G','G','G'],
e8d5ab0
-    ['F','F','F','F','F','D','D','D','D','D','D','F','D','G','F','D','G'],
e8d5ab0
-    ['D','D','D','D','D','D','D','D','D','D','D','D','D','G','D','D','G'],
e8d5ab0
-    ['G','G','G','G','G','G','G','G','G','G','G','G','G','G','G','G','G']
e8d5ab0
-    ],'S1')
e8d5ab0
+# This compares scalarmath against ufuncs.
e8d5ab0
 
e8d5ab0
 class test_types(ScipyTestCase):
e8d5ab0
     def check_types(self, level=1):
e8d5ab0
         # list of types
e8d5ab0
         for k, atype in enumerate(types):
e8d5ab0
             vala = atype(3)
e8d5ab0
+            val1 = array([3],dtype=atype)
e8d5ab0
             for l, btype in enumerate(types):
e8d5ab0
                 valb = btype(1)
e8d5ab0
+                val2 = array([1],dtype=btype)
e8d5ab0
                 val = vala+valb
e8d5ab0
-                assert val.dtype.num == typeconv[k,l] and \
e8d5ab0
-                       val.dtype.char == typeconv2[k,l], \
e8d5ab0
+                valo = val1 + val2
e8d5ab0
+                assert val.dtype.num == valo.dtype.num and \
e8d5ab0
+                       val.dtype.char == valo.dtype.char, \
e8d5ab0
                        "error with (%d,%d)" % (k,l)
e8d5ab0
+
e8d5ab0
+if __name__ == "__main__":
e8d5ab0
+    NumpyTest().run()