Repository navigation
Conversation
|
Linting is failing. Can you reflow the help text to 88 or less columns? |
introspection (numpygh-29824) This enhancement makes two related improvements to `np.vectorize`: - Adds `__signature__` and `__wrapped__` attributes to better expose the signature and docstring of the wrapped function. - Moves the `vectorize` class docstring into `__init__` to avoid cluttering with "Class Docstring" in Jupyter notebook tooltips. These changes were with user-defined functions, lambda functions, imported functions, and callable classes. The tooltip now correctly displays the function signature and docstring, though IPython still shows a redundant "Call Signature" field.
e168107 to
3fdfb84
Compare
|
Hello! I have re flowed the help text to less than 88 columns (Checked with ruff tool). Thank you! |
|
CC @jagerber48 in case you want to take a look. Can you check if the signature isn't also a bit of a stretch? I.e. the original signature probably allows passing non-positionally, but |
|
Can we have screenshots of the tooltip posted here like in the the issue thread? @seberg unfortunately I can't understand what you mean about "a bit of a stretch", |
|
I mean that you can't pass arguments by |
|
@jagerber48 Here is the screenshot of tooltip before vs after changes : @seberg I did not understand your comment (Sorry!). But, did you mean that if I test the following function: Define: And then try to get the function signature, I should get it properly? If so, here is the image showing these:
|
|
Sorry, I meant that the signature looks like you can call the vectorized function with |
|
Ah, I see! You mean that if the wrapped function only accepts positional arguments, then displaying a signature like Now, what is the best place to add it? Should we put this warning in the Notes section of numpy.vectorize? |
|
Yeah nvm though, seems vectorize does a crazy dance to support kwargs... I did not expect that. |
|
Ok, this looks good to me. It has the improvements we discussed. The only thing I don't like is the pesky "Call Signature" line that is wasting space. But per the discussion at #29824, it doesn't seem like it will be easy to remove that. Perhaps that could be out-of-scope for this PR and can be opened as a separate issue after this one is resolved. |
|
Thanks for clarifying, @seberg. Good to know about the keyword argument behavior! Let me know if there’s anything else you’d like me to adjust before merging. |
|
Hmmmm, I forgot about this. Should we just put this in? I expect the try/except is safe enough. |
|
@seberg, can you do something about this PR? I want to submit another PR for a different issue, but I am getting an error saying I have reached the maximum number of open pull requests. |
cfb42cf to
28c0c5e
Compare
|
I have updated this issue so as to resolve the merge conflict with the latest main. |


ENH: fix call signature display for np.vectorize during Jupyter introspection (gh-29824)
This enhancement makes two related improvements to
np.vectorize:Adds
__signature__and__wrapped__attributes to better expose the signature and docstring of the wrapped function.Moves the
vectorizeclass docstring into__init__to avoid cluttering with "Class Docstring" in Jupyter notebook tooltips.These changes were with user-defined functions, lambda functions, imported functions, and callable classes. The tooltip now correctly displays the function signature and docstring, though IPython still shows a redundant "Call Signature" field.