API: Add diagonal and trace to numpy.linalg [Array API]#24887
API: Add diagonal and trace to numpy.linalg [Array API]#24887charris merged 1 commit intonumpy:mainfrom
diagonal and trace to numpy.linalg [Array API]#24887Conversation
21c0a39 to
cefa7eb
Compare
diagonal and trace to numpy.linalgdiagonal and trace to numpy.linalg [Array API]
|
Thanks Mateusz. |
|
It looks that I forgot a release note file. I will add it in a follow-up PR. |
| Returns specified diagonals of a matrix (or a stack of matrices) ``x``. | ||
|
|
||
| This function is Array API compatible, contrary to | ||
| :py:func:`numpy.diagonal`. |
There was a problem hiding this comment.
Seeing this only because these new additions to the numpy API triggered astropy warnings, and perhaps too late since it is already merged, but wouldn't it be better to tell what the difference is here rather than what is here now? As is, this comment forces the user to either look up the array API or to look at the docstring of np.diagonal to find out that it is the axes that are used. Maybe add something like
"""
This function is Array API compatible, contrary to
:py:func:numpy.diagonal: the matrix is assumed
to be defined by the last two dimensions.
"""
There was a problem hiding this comment.
You're right - it's clearer about the difference. I will update the docstring.
Hi @rgommers @ngoldbaum,
This PR contains another set of small Array API compatibility changes. It adds
numpy.linalg.diagonalandnumpy.linalg.tracewith docs taken from Array API specification.