-
Notifications
You must be signed in to change notification settings - Fork 1
Clean up documentation #11
Comments
Shall we add a description of the arguments and return values to function docstrings? |
Yes, please. Anything that has missing or incomplete docstrings should be completed. |
I just saw, that functions, which are vectorized via np.vectorize do not appear in the documentation... One example is the flattop function in the pulse module. It also seems, that these functions are not even mentioned if one calls python's native help() function. I guess that, it might be due to the reason, that after the vectorization, the functions is a |
Interesting... That sounds like it should be reported as a bug to numpy. Maybe we'll have to work around this by having our own |
Actually numpy.vectorize seems to preserve docstrings, but the object it returns is no longer 'part' of the module. The returned wrapper is rather associated with numpy (help(vectorized_function) returns e.g. the help for vectorize). That's also the reason why I am a little hesitant to report this as a bug... One possible (hot)fix for this could be something like:
But this does not seem very elegant |
Definitely a bug in numpy, in my opinion (numpy/numpy#13826), although I'm not overly optimistic that this will get fixed (as they can arguably shift the blame to pydoc/Sphinx, and they might consider it a "breaking change"). In principle, we could add something like the following to def vectorize_function(pyfunc, **kwargs):
"""Function decorator acting like :class:`numpy.vectorize`.
All arguments are passed to :class:`numpy.vectorize`. Unlike
:class:`numpy.vectorize`, this decorator does not convert the decorated
function into an instance of the :class:`numpy.vectorize` class. As a
result, the decorated function's docstring will be taken into account
properly by doc generators (pydoc or Sphinx)
"""
wrapped = np.vectorize(pyfunc, **kwargs)
@functools.wraps(pyfunc)
def run_wrapped(*args, **kwargs):
return wrapped(*args, **kwargs)
run_wrapped.__doc__ = wrapped.__doc__ # preserve np.vectorize's `doc` arg
return run_wrapped The name Let's just avoid using |
ok, we'll see what happens. Thanks for the numpy issue! |
The documentation is currently not in great shape, with lots of errors being reported, and the corresponding glitches in the generated HTML.
docs.log
All of these need to be fixed, and every HTML file in the API should be checked manually for readability. Some docstrings may not fully match the requirements of the Google Style. The
krotov
package (whose API docs are in perfect shape) provides good examples for what to do, if in doubt.These fixes are in addition the some more in-depth sections in the documentation that explain concepts and connections, beyond just the API. Writing these long-form documents would benefit significantly from #8, allowing to make connections to the QDYN documentation.
The text was updated successfully, but these errors were encountered: