Skip to content

[PATCH] interactive docstring search (lookfor) (Trac #734) #1332

Closed

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/734 on 2008-04-10 by @pv, assigned to unknown.

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.

Activity

  1. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    Attachment added by @pv on 2008-04-10: ticket-734-lookfor.patch

  2. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @teoliphant wrote on 2008-04-11

    Added in r5024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions