Skip to content

Remove axisN keyword arguments from linalg.diag and linalg.trace #241

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 1 commit into from
Aug 19, 2021

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Aug 16, 2021

This PR

  • removes the axis1 and axis2 keyword arguments from linalg.diag and linalg.trace.
  • updates the API to perform batching over the last two dimensions.
  • supersedes gh-222.

Background

linalg.diag and linalg.trace, as currently specified, are unique in their parameterization. Namely, for APIs which allow specification of axes, common convention is to use axis or axes. Furthermore, prior art (NumPy) used 0 and 1 as the default axes, which runs counter to the current prevalent practice of batching along the last (innermost) two dimensions.

gh-215 proposed changing the defaults to -2 and -1, respectively. Subsequent discussion (both in gh-215 and in consortium meeting 2021-07-29) contended that they should be removed altogether.

This PR follows consensus found in the consortium meeting to simply remove the axisN keyword arguments. If future needs arise to specify axes in the future, such additions can be made to the specification in a future revision.

@rgommers rgommers added the Maintenance Bug fix, typo fix, or general maintenance. label Aug 19, 2021
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

This was decided a while ago and everyone seems happy. Let's get it in. Thanks @kgryte.

@leofang
Copy link
Contributor

leofang commented Aug 19, 2021

Thanks, @kgryte!

asmeurer added a commit to asmeurer/numpy that referenced this pull request Oct 7, 2021
The NumPy versions operate on the first two axes, but the array API diagonal
should operate on the last two, so that they work correctly on stacks of
matrices. See data-apis/array-api#241.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Bug fix, typo fix, or general maintenance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants