Skip to content
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

[RFC]: make axis kwarg optional in squeeze #892

Open
ev-br opened this issue Feb 4, 2025 · 1 comment
Open

[RFC]: make axis kwarg optional in squeeze #892

ev-br opened this issue Feb 4, 2025 · 1 comment
Labels
API change Changes to existing functions or objects in the API. Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes. topic: Manipulation Array manipulation and transformation.

Comments

@ev-br
Copy link

ev-br commented Feb 4, 2025

Cross-referencing from data-apis/array-api-strict#62 :

The standard's version of squeeze has axis as a required argument (https://data-apis.org/array-api/2023.12/API_specification/generated/array_api.squeeze.html#array_api.squeeze), while virtually all array libraries allow axis=None with the semantics of "remove all singleton dimensions":

  • torch.squeeze(input: Tensor, dim: Optional[Union[int, List[int]]])
  • numpy.squeeze(a, axis=None)
  • jax.numpy.squeeze(a, axis=None)

Is there any deep reason to not follow the suit and allow the axis to be Optional[ int | tuple]?

@jakevdp
Copy link

jakevdp commented Feb 4, 2025

Related discussion: #100. In particular, this comment: #100 (comment)

I don't think we need "clean up size-1 dimensions if they exist" in the API standard. Squeezing without an axis really only makes sense in an interactive context, but our primary audience here is library developers.

@kgryte kgryte changed the title make axis optional in squeeze [RFC]: make axis kwarg optional in squeeze Feb 4, 2025
@kgryte kgryte added RFC Request for comments. Feature requests and proposed changes. API change Changes to existing functions or objects in the API. topic: Manipulation Array manipulation and transformation. Needs Discussion Needs further discussion. labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change Changes to existing functions or objects in the API. Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes. topic: Manipulation Array manipulation and transformation.
Projects
None yet
Development

No branches or pull requests

3 participants