Skip to content

Standardizes axis validation and handling in array_api/statistical_functions.py - #4909

Merged
ajpotts merged 1 commit into
Bears-R-Us:mainfrom
drculhane:Closes-4905
Sep 22, 2025
Merged

ajpotts merged 1 commit into
Bears-R-Us:mainfrom
drculhane:Closes-4905

Conversation

@drculhane

@drculhane drculhane commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Closes #4905

The primary intent of this PR was to add the new standard axis validation & handling to array_api/statistical_functions.py. Along the way, I noted other issues.

  • The docstrings were very incomplete. I have attempted to fix that.
  • The unit test for array_api's mean had a print statement where there should have been an assert. Fixed.
  • There are two comments in statistical_functions.py that I believe are out of date: lines 298 and 449, if my notes are correct. I'm inclined to delete them (holding off on that for a later revision).

NOTE: some of the functions are just pass-throughs (i.e. no code except for calling another function). In those cases, I've chosen not to check the axis parameter (since the other function has to), nor to include the corresponding errors in the Raises section, even though I may have included Examples. This is purely a judgment call, and I'm open to discussion.

@1RyanK

1RyanK commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

From here looks like in the docstring after the description, it's supposed to go Parameters -> Returns -> Raises -> Examples, if we're following numpy.

@1RyanK 1RyanK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Maybe just standardize the order of sections in the docstrings.

@drculhane

drculhane commented Sep 19, 2025 •

Copy link
Copy Markdown
Contributor Author

I took Ryan's suggestion of standardizing the order of the docstring sections. That's the only change in this latest push.

@ajpotts ajpotts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Thanks for improving this.

@ajpotts
ajpotts added this pull request to the merge queue Sep 22, 2025
Merged via the queue into Bears-R-Us:main with commit 55c4149 Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update axis handling in array_api/statistical_functions.py

3 participants