FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: Add a `__dict__` to ufunc objects and allow overriding `__doc__` by mtsokol · Pull Request #27735 · numpy/numpy · GitHub

/ numpy Public

ENH: Add a __dict__ to ufunc objects and allow overriding __doc__ - #27735

Merged
ngoldbaum merged 7 commits into
numpy:mainfrom
mtsokol:ufunc-object-dict
Nov 13, 2024
Merged

ngoldbaum merged 7 commits into
numpy:mainfrom
mtsokol:ufunc-object-dict

Conversation

mtsokol commented Nov 11, 2024

Copy link
Copy Markdown
Member

Hi @ngoldbaum, @mhvk,

This PR fixes #26233 and replaces #27383 (with existing review comments applied).

… `__doc__`

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>

mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Apart from the nitpick on the tests, this looks great!

seberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

FWIW, looks fine to me as well, but also some comments. I mostly still think that we should also note other things like module and qualname (which have very clear use-cases as well).

Comment thread numpy/_core/src/umath/ufunc_object.c Outdated
mtsokol force-pushed the ufunc-object-dict branch 3 times, most recently from ccdeffb to 1aae07d Compare November 12, 2024 13:37
Comment thread numpy/_core/src/umath/ufunc_object.c Outdated

Copy link
Copy Markdown
Member

As a followup we should probably set __module__ on all of NumPy's built-in ufuncs so they show up where they're supposed to be in the public API instead of _multiarray_umath

Copy link
Copy Markdown
Member

Maybe we can sneak in a deprecation warning into _add_newdoc_ufunc in this PR? It’s in np._core but we told people to continue using it because of the issue fixed by this PR.

mtsokol commented Nov 12, 2024

Copy link
Copy Markdown
Member Author

Maybe we can sneak in a deprecation warning into _add_newdoc_ufunc in this PR?

@ngoldbaum Done!

I think all is ready now.

``__qualname__``.

* ``_add_newdoc_ufunc`` is now deprecated. ``ufunc.__doc__ = newdoc`` should
be used instead. No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit, but it should be split into two files (different categories).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah right, done!

mattip commented Nov 13, 2024

Copy link
Copy Markdown
Member

We discussed this at the triage meeting and would like to see it merged in.

Copy link
Copy Markdown
Member

I gave the C code another once-over and I think this is correct. I'll merge now. We should definitely update the way we set docstrings internally to make use of this as a followup, fixing #10167 too.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: add __dict__ to the ufunc object

5 participants


Back | FazBrowse Home | New Git URL