Skip to content

ENH: test take_along_axis #367

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

ev-br
Copy link
Member

@ev-br ev-br commented Apr 21, 2025

Towards gh-299: add testing of take_along_axis.

@ev-br
Copy link
Member Author

ev-br commented Apr 21, 2025

The spec requires that axis=-1 has a default value. Pretty much all libraries differ:

  • jax.numpy : axis is a required argument. jax does not support the 2024.12 revision yet though.
  • numpy: axis is a required argument.
  • cupy: axis is a required argument
  • torch: dim=None defaults to None, but the documentation states that dim=None ravels.
  • dask.array: does not implement take_along_axis at all.

data-apis/array-api-compat#317 works around it for numpy and cupy; torch was alread covered; dask.array will need a test skip in data-apis/array-api-compat#317.

cc @crusaderky for dask

@ev-br
Copy link
Member Author

ev-br commented Apr 21, 2025

Ran locally the combination of this test and data-apis/array-api-compat#317, for 10_000 examples on each of torch, cupy and numpy.

$ ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64 ARRAY_API_TESTS_MODULE=array_api_compat.torch pytest array_api_tests/test_indexing_functions.py::test_take_along_axis -v  --max-examples=10_000

@crusaderky
Copy link
Contributor

Don't expect a dask implementation anytime soon: dask/dask#3663
Best we can do is hack together something in array-api-compat that rechunks to a single chunk, much like it already happens for sort and argsort. This will work on a "better than nothing" basis, with very big performance caveats.

@ev-br
Copy link
Member Author

ev-br commented Apr 21, 2025

Thanks, will add a skip with the link to the dask issue then.

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.

2 participants