Skip to content

Closes 4831, standardizes axis checking for cases where axis can only be an integer - #4834

Merged
ajpotts merged 1 commit into
Bears-R-Us:mainfrom
drculhane:Alternate-4800
Sep 3, 2025
Merged

ajpotts merged 1 commit into
Bears-R-Us:mainfrom
drculhane:Alternate-4800

Conversation

@drculhane

@drculhane drculhane commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Closes #4831, which is a subset of #4800

This covers the cases where the axis parameter can only be an integer. This only applies to array_api and numpy functions, and not the pandas functions (where axis can be 0 or 1, "index" or "columns").

It doesn't cover the cases where the axis parameter can be a tuple.

Quick summary:

There is now a function in numpy/util.py called _integer_axis_validation. It returns a bool and an int. If the bool is false, the given axis wasn't valid, and in (I think) every case, an IndexError is raised.

There are several functions in array_api that just pass their parameters to arkouda/numpy functions with the same name. In those cases, I don't bother to check at the array_api level.

Note that array_api's vecdot accepted an axis parameter, but didn't use it. I changed that so that it passes the axis argument to the numpy function. Also note that vecdot handles the axis validation differently than other functions, so it doesn't use the standard validation.

Also also note that expand_dims and stack are unique in that they check the validity against a rank 1 greater than the given input.

@drculhane
drculhane force-pushed the Alternate-4800 branch 2 times, most recently from a63a7ce to 7ada2dd Compare August 29, 2025 13:44

@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!

@jaketrookman jaketrookman 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

@ajpotts
ajpotts added this pull request to the merge queue Aug 29, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Aug 29, 2025
@ajpotts
ajpotts added this pull request to the merge queue Sep 3, 2025
Merged via the queue into Bears-R-Us:main with commit f0a9609 Sep 3, 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.

Standardize axis handling where the axis can only be an integer, not a tuple

4 participants