BUG, DOC: np.generic missing method runtime signatures and docs
#30193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the
inspect.signatureerrors for 50+ methods of the numpy scalar types. To avoid code duplication, I added a cute little helper function that takes care of both the method docstrings ofndarrayandgenericat the same time, as well as the__text_signature__.To make things a bit easer for myself, I simplified the
ndarray-referencing docstrings of thegenericmethods a bit, so that they fit on one line. But it could easily be expanded now, or even automatically kept in sync with thendarraymethod docs.This also adds docstrings to
generic.to_device()andgeneric.tobytes(), because they were completely missing.Anyway, to make a long story even longer; the following
genericandlonglongmethods will now no longer causeinspect.signatureto raise aValueError(puns intended), including:np.generic.__array_namespace__np.generic.__copy__np.generic.__deepcopy__np.generic.allnp.generic.anynp.generic.argmaxnp.generic.argminnp.generic.argsortnp.generic.astypenp.generic.byteswapnp.generic.choosenp.generic.clipnp.generic.compressnp.generic.conjnp.generic.conjugatenp.generic.copynp.generic.cumprodnp.generic.cumsumnp.generic.diagonalnp.generic.dumpnp.generic.dumpsnp.generic.fillnp.generic.flattennp.generic.getfieldnp.generic.itemnp.generic.maxnp.generic.meannp.generic.minnp.generic.nonzeronp.generic.prodnp.generic.putnp.generic.ravelnp.generic.repeatnp.generic.reshapenp.generic.resizenp.generic.roundnp.generic.searchsortednp.generic.setfieldnp.generic.setflagsnp.generic.sortnp.generic.squeezenp.generic.stdnp.generic.sumnp.generic.swapaxesnp.generic.takenp.generic.to_devicenp.generic.tobytesnp.generic.tofilenp.generic.tolistnp.generic.tracenp.generic.transposenp.generic.varnp.generic.viewnp.ulonglong.bit_countnp.longlong.bit_countRelated to #30104, #30114, #30121, #30124, #30126, #30137, #30138, #30140, #30143, #30146, #30147, #30155, and #30164, #30169