[Numpy-svn] r8533 - branches/1.5.x/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Jul 28 16:20:34 EDT 2010


Author: ptvirtan
Date: 2010-07-28 15:20:34 -0500 (Wed, 28 Jul 2010)
New Revision: 8533

Modified:
   branches/1.5.x/numpy/lib/utils.py
Log:
BUG: (backport r8532) fix usability bugs in lookfor

- allow numbers in function signature

- print the items in relevance order (not reverse relevance)

- include ufunc docstrings

Modified: branches/1.5.x/numpy/lib/utils.py
===================================================================
--- branches/1.5.x/numpy/lib/utils.py	2010-07-28 20:19:25 UTC (rev 8532)
+++ branches/1.5.x/numpy/lib/utils.py	2010-07-28 20:20:34 UTC (rev 8533)
@@ -4,7 +4,7 @@
 import re
 
 from numpy.core.numerictypes import issubclass_, issubsctype, issubdtype
-from numpy.core import product, ndarray
+from numpy.core import product, ndarray, ufunc
 
 __all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', 'issubdtype',
         'deprecate', 'deprecate_with_doc', 'get_numarray_include',
@@ -695,7 +695,7 @@
 _lookfor_caches = {}
 
 # regexp whose match indicates that the string may contain a function signature
-_function_signature_re = re.compile(r"[a-z_]+\(.*[,=].*\)", re.I)
+_function_signature_re = re.compile(r"[a-z0-9_]+\(.*[,=].*\)", re.I)
 
 def lookfor(what, module=None, import_modules=True, regenerate=False,
             output=None):
@@ -797,7 +797,7 @@
     # Pretty-print
     s = "Search results for '%s'" % (' '.join(whats))
     help_text = [s, "-"*len(s)]
-    for name in found:
+    for name in found[::-1]:
         doc, kind, ix = cache[name]
 
         doclines = [line.strip() for line in doc.strip().split("\n")
@@ -931,8 +931,12 @@
                     item_name = "%s.%s" % (mod_name, item_name)
 
                 if not item_name.startswith(name + '.'):
-                    # don't crawl foreign objects
-                    continue
+                    # don't crawl "foreign" objects
+                    if isinstance(v, ufunc):
+                        # ... unless they are ufuncs
+                        pass
+                    else:
+                        continue
                 elif not (inspect.ismodule(v) or _all is None or n in _all):
                     continue
                 stack.append(("%s.%s" % (name, n), v))
@@ -940,9 +944,6 @@
             kind = "class"
             for n, v in _getmembers(item):
                 stack.append(("%s.%s" % (name, n), v))
-        # FIXME later: workaround python3.1 capsule callable bug
-        # by using old version of callable.
-        # elif callable(item):
         elif hasattr(item, "__call__"):
             kind = "func"
 




More information about the Numpy-svn mailing list