Skip to content

Instantly share code, notes, and snippets.

@stefanv
Created November 9, 2011 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanv/1352940 to your computer and use it in GitHub Desktop.
Save stefanv/1352940 to your computer and use it in GitHub Desktop.
Illustration of possible extra documentation for generic SciPy optimization interface.
def minimize_doc(method=None):
"""Additional arguments for SciPy minimisers.
* BFGS
- Arg 1 descr
- Arg 2 descr
* Newton
- Newton arg 1
- Newton arg 2
"""
if method is None:
print minimize_doc.__doc__
else:
sections = minimize_doc.__doc__.split('*')[1:]
sections = [s.strip() for s in sections]
sections = [s for s in sections if s.startswith(method)]
print '\n'.join(sections)
if __name__ == "__main__":
print 'Print everything:'
minimize_doc()
print "Let's ask for Newton only:"
minimize_doc('Newton')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment