[Numpy-svn] r3647 - in trunk/numpy: core/tests oldnumeric

numpy-svn@scip... numpy-svn@scip...
Mon Apr 2 16:24:56 CDT 2007


Author: oliphant
Date: 2007-04-02 16:24:52 -0500 (Mon, 02 Apr 2007)
New Revision: 3647

Modified:
   trunk/numpy/core/tests/test_multiarray.py
   trunk/numpy/oldnumeric/arrayfns.py
Log:
Add a few more functions to arrayfns compatibility file and fix typo.

Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py	2007-04-02 20:26:47 UTC (rev 3646)
+++ trunk/numpy/core/tests/test_multiarray.py	2007-04-02 21:24:52 UTC (rev 3647)
@@ -377,11 +377,12 @@
                     x.clip(clip_min,clip_max,x)
                 else:
                     x = x.clip(clip_min,clip_max)
+                    byteorder = '='
 
                 if x.dtype.byteorder == '|': byteorder = '|'
                 assert_equal(byteorder,x.dtype.byteorder)
                 self._check_range(x,expected_min,expected_max)
-                return x
+        return x
 
     def check_basic(self):
         for inplace in [False, True]: 

Modified: trunk/numpy/oldnumeric/arrayfns.py
===================================================================
--- trunk/numpy/oldnumeric/arrayfns.py	2007-04-02 20:26:47 UTC (rev 3646)
+++ trunk/numpy/oldnumeric/arrayfns.py	2007-04-02 21:24:52 UTC (rev 3647)
@@ -22,17 +22,9 @@
         raise error, "vals1 and vals2 must have same number of dimensions (>=1)"
     vals1[indices] = vals2
 
-def construct3(mask, itype):
-    raise NotImplementedError
-
 from numpy import digitize
+from numpy import bincount as histogram
 
-def find_mask(fs, node_edges):
-    raise NotImplementedError
-
-def histogram(lst, weight=None):
-    raise NotImplementedError
-
 def index_sort(arr):
     return asarray(arr).argsort(kind='heap')
 
@@ -67,16 +59,40 @@
 
 def span(lo, hi, num, d2=0):
     x = linspace(lo, hi, num)
-    if d2 <= 0
+    if d2 <= 0:
         return x
     else:
         ret = empty((d2,num),x.dtype)
         ret[...] = x
         return ret
 
+def zmin_zmax(z, ireg):
+    z = asarray(z, dtype=float)
+    ireg = asarray(ireg, dtype=int)
+    if z.shape != ireg.shape or z.ndim != 2:
+        raise ValueError, "z and ireg must be the same shape and 2-d"
+    ix, iy = nx.nonzero(ireg)
+    # Now, add more indices
+    x1m = ix - 1
+    y1m = iy-1
+    i1 = x1m>=0
+    i2 = y1m>=0
+    i3 = i1 & i2
+    nix = nx.r_[ix, x1m[i1], x1m[i1], ix[i2] ]
+    niy = nx.r_[iy, iy[i1],  y1m[i3], y1m[i2]]
+    # remove any negative indices
+    zres = z[nix,niy]
+    return zres.min().item(), zres.max().item()
+
+
+def find_mask(fs, node_edges):
+    raise NotImplementedError
+
 def to_corners(arr, nv, nvsum):
     raise NotImplementedError
 
-def zmin_zmax(z, ireg):
+
+def construct3(mask, itype):
     raise NotImplementedError
-        
+
+



More information about the Numpy-svn mailing list