Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 13, 2024

Conversation

mtsokol
Copy link
Member

@mtsokol mtsokol commented Nov 11, 2024

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>
Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

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

numpy/_core/tests/test_umath.py Show resolved Hide resolved
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

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).

numpy/_core/src/umath/ufunc_object.c Show resolved Hide resolved
doc/release/upcoming_changes/27735.new_feature.rst Outdated Show resolved Hide resolved
numpy/_core/src/umath/ufunc_object.c Outdated Show resolved Hide resolved
@mtsokol mtsokol force-pushed the ufunc-object-dict branch 3 times, most recently from ccdeffb to 1aae07d Compare November 12, 2024 13:37
@ngoldbaum
Copy link
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

@ngoldbaum
Copy link
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
Copy link
Member Author

mtsokol commented Nov 12, 2024

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.
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, done!

@mattip
Copy link
Member

mattip commented Nov 13, 2024

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

@ngoldbaum
Copy link
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.

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.