[Scipy-svn] r2150 - in trunk/Lib: linalg misc sandbox/models sandbox/xplt stats

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Aug 5 02:52:54 CDT 2006


Author: oliphant
Date: 2006-08-05 02:52:47 -0500 (Sat, 05 Aug 2006)
New Revision: 2150

Modified:
   trunk/Lib/linalg/decomp.py
   trunk/Lib/misc/pilutil.py
   trunk/Lib/sandbox/models/bsplines.py
   trunk/Lib/sandbox/models/utils.py
   trunk/Lib/sandbox/xplt/colorbar.py
   trunk/Lib/sandbox/xplt/slice3.py
   trunk/Lib/stats/distributions.py
Log:
Make use of flatnonzero

Modified: trunk/Lib/linalg/decomp.py
===================================================================
--- trunk/Lib/linalg/decomp.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/linalg/decomp.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -32,7 +32,7 @@
 _I = cast['F'](1j)
 def _make_complex_eigvecs(w,vin,cmplx_tcode):
     v = numpy.array(vin,dtype=cmplx_tcode)
-    ind = numpy.nonzero(numpy.not_equal(w.imag,0.0))
+    ind = numpy.flatnonzero(numpy.not_equal(w.imag,0.0))
     vnew = numpy.zeros((v.shape[0],len(ind)>>1),cmplx_tcode)
     vnew.real = numpy.take(vin,ind[::2],1)
     vnew.imag = numpy.take(vin,ind[1::2],1)

Modified: trunk/Lib/misc/pilutil.py
===================================================================
--- trunk/Lib/misc/pilutil.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/misc/pilutil.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -157,9 +157,9 @@
     # Check for 3 in datacube shape --- 'RGB' or 'YCbCr'
     if channel_axis is None:
         if (3 in shape):
-            ca = numpy.nonzero(asarray(shape) == 3)[0]
+            ca = numpy.flatnonzero(asarray(shape) == 3)[0]
         else:
-            ca = numpy.nonzero(asarray(shape) == 4)
+            ca = numpy.flatnonzero(asarray(shape) == 4)
             if len(ca):
                 ca = ca[0]
             else:

Modified: trunk/Lib/sandbox/models/bsplines.py
===================================================================
--- trunk/Lib/sandbox/models/bsplines.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/sandbox/models/bsplines.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -161,7 +161,7 @@
 
         # throw out rows with zeros (this happens at boundary points!)
 
-        mask = N.nonzero(1 - N.alltrue(N.equal(bt, 0), axis=0))
+        mask = N.flatnonzero(1 - N.alltrue(N.equal(bt, 0), axis=0))
 
         bt = bt[:,mask]
         y = y[mask]

Modified: trunk/Lib/sandbox/models/utils.py
===================================================================
--- trunk/Lib/sandbox/models/utils.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/sandbox/models/utils.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -40,10 +40,8 @@
     """
     Erase columns of zeros: can save some time in pseudoinverse.
     """
-
     colsum = N.add.reduce(matrix**2, 0)
-    
-    val = [matrix[:,i] for i in N.nonzero(colsum)]
+    val = [matrix[:,i] for i in N.flatnonzero(colsum)]
     return N.array(N.transpose(val))
 
 def rank(X, cond=1.0e-12):

Modified: trunk/Lib/sandbox/xplt/colorbar.py
===================================================================
--- trunk/Lib/sandbox/xplt/colorbar.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/sandbox/xplt/colorbar.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -9,6 +9,7 @@
 from numpy import *
 from gist import *
 from slice3 import *
+from numpy.oldnumeric import nonzero
 
 def nice_levels (z, n = 8) :
     """nice_levels(z, n = 8) finds approximately n "nice values"

Modified: trunk/Lib/sandbox/xplt/slice3.py
===================================================================
--- trunk/Lib/sandbox/xplt/slice3.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/sandbox/xplt/slice3.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -22,6 +22,7 @@
 from numpy import *
 from gistC import *
 from gistfuncs import *
+from numpy.oldnumeric import nonzero
 
  #
  # Caveats:

Modified: trunk/Lib/stats/distributions.py
===================================================================
--- trunk/Lib/stats/distributions.py	2006-08-05 07:27:52 UTC (rev 2149)
+++ trunk/Lib/stats/distributions.py	2006-08-05 07:52:47 UTC (rev 2150)
@@ -17,7 +17,7 @@
      any, argsort, argmax, vectorize, r_, asarray, nan, inf, pi, isnan, isinf
 import numpy
 import numpy.random as mtrand
-from numpy.oldnumeric import nonzero
+from numpy import flatnonzero as nonzero
 
 __all__ = [
            'rv_continuous',



More information about the Scipy-svn mailing list