[Numpy-tickets] [NumPy] #734: [PATCH] interactive docstring search (lookfor)

NumPy numpy-tickets@scipy....
Thu Apr 10 15:47:45 CDT 2008


#734: [PATCH] interactive docstring search (lookfor)
-------------------------+--------------------------------------------------
 Reporter:  pv           |       Owner:  somebody          
     Type:  enhancement  |      Status:  new               
 Priority:  normal       |   Milestone:  1.0.5             
Component:  Other        |     Version:  none              
 Severity:  normal       |    Keywords:  lookfor doc search
-------------------------+--------------------------------------------------
 It'd be nice to have a docstring search that could be used interactively:
 {{{
 >>> import numpy as np
 >>> np.lookfor("eigenvalue hermitean")
 Search results for 'eigenvalue hermitean'
 -----------------------------------------
 numpy.linalg.eigvalsh
     Compute the eigenvalues of a Hermitean or real symmetric matrix.
 numpy.linalg.eigh
     Compute eigenvalues for a Hermitian or real symmetric matrix.
 numpy.linalg.eigvals
     Compute the eigenvalues of a general matrix.
 >>> np.lookfor("spline interpolat", module="scipy")
 Search results for 'spline interpolat'
 --------------------------------------
 scipy.interpolate.spline
     Interpolate a curve (xk,yk) at points xnew using a spline fit.
 scipy.interpolate.RectBivariateSpline
     Bivariate spline approximation over a rectangular mesh.
 scipy.interpolate.InterpolatedUnivariateSpline
     Interpolated univariate spline approximation. Identical to
 scipy.ndimage.shift
     Shift an array.
 scipy.ndimage.zoom
     Zoom an array.
 scipy.interpolate.splrep
     Find the B-spline representation of 1-D curve.
 ... long result, shown in a pager ...
 }}}

 This patch implements a simple-minded docstring search:
   - _lookfor_generate_cache walks the contents of the module to search,
 collecting docstrings
   - lookfor splits the search string and searchs for entries that contain
 all parts. No stemming etc. is done.
   - lookfor sorts the results by a Harrison-Stetson relevancy metric (ie.
 I just wrote up some heuristics to distinguish "more relevant" results
 from "less relevant"). It appears to work ok, but probably could be
 improved.
   - lookfor either prints or calls a pager (via pydoc, for long listings)
 to show the results

 No automated tests at this time, sorry, I only did manual testing now.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/734>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list