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
ENH: Restore numpy.lib.add_newdoc_ufunc #26233
Comments
This function messes with the |
Not sure how much you need it, I am tempted to say: just use the private version. We will keep pretending that we can just delete it at some point (i.e. doing this break in some future), but I don't expect that future to happen very soon. |
What about a patch to add a setter for the doc property? |
@lpsinger if that works, that seems like a good idea to me. UFuncs currently do not have a The one caveat is that it might be better to not modify the size of the ufunc object in bug-fix releases (we may actually have some empty slots, though). EDIT: Sorry for double post, github was misbehaving. |
FWIW, this is a feature I would like, but it was never a high enough priority to investigate an implementation. The use-case is a function where an integer parameter is effectively an enum, and I wanted to store the allowed values as attributes on the ufunc. See the fifth bullet of the list here: https://github.com/WarrenWeckesser/numpy-notes/blob/main/enhancements/gufunc-wishlist.md |
Hmm, unfortunately >>> func.__doc__ = 'foo'
>>> assert func.__doc__ == 'foo' would fail. What about adding a |
The funcion `add_newdoc_ufunc` is no longer part of the Numpy public API, although according to upstream developers it is not going away any time soon. See numpy/numpy#26233.
Maybe a setter can work, though? You could give it a logic of:
If we add the |
The problem is that the getter for >>> obj.prop = value
>>> assert obj.prop == value Are you OK with that? |
Ah, you are right. I thought we would ask you to include the signature in your doc string, but that isn't great. (There was some discussion about using |
I haven't followed in detail, but just a quick note that there is recent discussion/work on |
Just to come back: if assignment to |
Proposed new feature or change:
I maintain several Python packages with C extensions that define ufuncs and generalized ufuncs. I have been relying upon the
add_newdoc_ufunc
function to add docstrings to those functions because it is such a pain to write legible multiline strings in C. According to the Numpy 2.0.0 migration guide,add_newdoc_ufunc
is "an internal function and doesn’t have a replacement." Is it possible to add it back to the public namespace asnumpy.lib.add_newdoc_ufunc
?The text was updated successfully, but these errors were encountered: