Skip to content

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

Merged
rgommers merged 1 commit into
mainfrom
update-diag-trace
Aug 19, 2021
Merged

rgommers merged 1 commit into
mainfrom
update-diag-trace

Conversation

@kgryte

@kgryte kgryte commented Aug 16, 2021 •

Copy link
Copy Markdown
Contributor

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

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

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

leofang commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

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