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
API: Add diagonal
and trace
to numpy.linalg
[Array API]
#24887
Conversation
21c0a39
to
cefa7eb
Compare
diagonal
and trace
to numpy.linalg
diagonal
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - it's clearer about the difference. I will update the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi @rgommers @ngoldbaum,
This PR contains another set of small Array API compatibility changes. It adds
numpy.linalg.diagonal
andnumpy.linalg.trace
with docs taken from Array API specification.