[Scipy-svn] r2151 - trunk/Lib/misc

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Aug 5 16:24:47 EDT 2006


Author: oliphant
Date: 2006-08-05 15:24:43 -0500 (Sat, 05 Aug 2006)
New Revision: 2151

Modified:
   trunk/Lib/misc/__init__.py
   trunk/Lib/misc/common.py
Log:
Move source, info, and who to NumPy

Modified: trunk/Lib/misc/__init__.py
===================================================================
--- trunk/Lib/misc/__init__.py	2006-08-05 07:52:47 UTC (rev 2150)
+++ trunk/Lib/misc/__init__.py	2006-08-05 20:24:43 UTC (rev 2151)
@@ -1,12 +1,18 @@
 
 from info import __doc__
 
-__all__ = ['limits']
+__all__ = ['limits', 'who', 'source', 'info']
 
 import limits
 from common import *
-from helpmod import *
+from numpy import who, source, info as _info
 
+import sys
+def info(object=None,maxwidth=76,output=sys.stdout,toplevel='scipy'):
+    return _info(object, maxwidth, output, toplevel)
+info.__doc__ = _info.__doc__
+del sys
+
 try:
     from pilutil import *
     __all__ += pilutil.__all__
@@ -14,7 +20,6 @@
     pass
 
 __all__ += common.__all__
-__all__ += helpmod.__all__
 
 from numpy.testing import ScipyTest
 test = ScipyTest().test

Modified: trunk/Lib/misc/common.py
===================================================================
--- trunk/Lib/misc/common.py	2006-08-05 07:52:47 UTC (rev 2150)
+++ trunk/Lib/misc/common.py	2006-08-05 20:24:43 UTC (rev 2151)
@@ -11,7 +11,9 @@
      newaxis, hstack, product, array, where, \
      zeros, extract, insert, pi, sqrt, eye, poly1d, dot, r_
 
-__all__ = ['factorial','factorial2','factorialk','comb','who',
+from numpy import who
+
+__all__ = ['factorial','factorial2','factorialk','comb', 
            'central_diff_weights', 'derivative', 'pade', 'lena']
 
 # XXX: the factorial functions could move to scipy.special, and the others
@@ -223,7 +225,6 @@
     q = r_[1.0,pq[n+1:]]
     return poly1d(p[::-1]), poly1d(q[::-1])
 
-# XXX: broken since plt is gone
 def lena():
     import cPickle, os
     fname = os.path.join(os.path.dirname(__file__),'lena.dat')
@@ -232,65 +233,3 @@
     f.close()
     return lena
 
-
-#-----------------------------------------------------------------------------
-# Matlab like functions for output and information on the variables used.
-#-----------------------------------------------------------------------------
-
-def who(vardict=None):
-    """Print the scipy arrays in the given dictionary (or globals() if None).
-    """
-    if vardict is None:
-        frame = sys._getframe().f_back
-        vardict = frame.f_globals
-    sta = []
-    cache = {}
-    for name in vardict.keys():
-        if isinstance(vardict[name],numpy.ndarray):
-            var = vardict[name]
-            idv = id(var)
-            if idv in cache.keys():
-                namestr = name + " (%s)" % cache[idv]
-                original=0
-            else:
-                cache[idv] = name
-                namestr = name
-                original=1
-            shapestr = " x ".join(map(str, var.shape))
-            bytestr = str(var.itemsize*numpy.product(var.shape))
-            sta.append([namestr, shapestr, bytestr, var.dtype.name,
-                        original])
-
-    maxname = 0
-    maxshape = 0
-    maxbyte = 0
-    totalbytes = 0
-    for k in range(len(sta)):
-        val = sta[k]
-        if maxname < len(val[0]):
-            maxname = len(val[0])
-        if maxshape < len(val[1]):
-            maxshape = len(val[1])
-        if maxbyte < len(val[2]):
-            maxbyte = len(val[2])
-        if val[4]:
-            totalbytes += int(val[2])
-
-    max = numpy.maximum
-    if len(sta) > 0:
-        sp1 = max(10,maxname)
-        sp2 = max(10,maxshape)
-        sp3 = max(10,maxbyte)
-        prval = "Name %s Shape %s Bytes %s Type" % (sp1*' ', sp2*' ', sp3*' ')
-        print prval + "\n" + "="*(len(prval)+5) + "\n"
-
-    for k in range(len(sta)):
-        val = sta[k]
-        print "%s %s %s %s %s %s %s" % (val[0], ' '*(sp1-len(val[0])+4),
-                                        val[1], ' '*(sp2-len(val[1])+5),
-                                        val[2], ' '*(sp3-len(val[2])+5),
-                                        val[3])
-    print "\nUpper bound on total bytes  =       %d" % totalbytes
-    return
-
-#-----------------------------------------------------------------------------




More information about the Scipy-svn mailing list