-
Notifications
You must be signed in to change notification settings - Fork 33
TST: Redesign test_all
#315
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR overhauls the testing of exported names by replacing the old test_all function with new, more focused tests and by standardizing the dir implementations across multiple array_api_compat modules. Key changes include:
- Replacing the test_all function with new tests (test_dir and test_builtins_collision) that better validate module exports.
- Removing redundant _all_ignore variables and cleaning up all definitions and dir implementations in various modules.
- Consolidating all settings in numpy, torch, dask, cupy, and common modules for more consistent behavior.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/test_all.py | New tests using NAMES/XFAILS and updated parameterizations replacing test_all. |
array_api_compat/torch/linalg.py | Removed _all_ignore and cleaned up all and dir definitions. |
array_api_compat/torch/fft.py | Removed _all_ignore; standardized dir definition. |
array_api_compat/torch/_aliases.py | Removed _all_ignore to simplify export handling. |
array_api_compat/numpy/linalg.py | Revised all composition and removed redundant concatenation of all. |
array_api_compat/numpy/fft.py | Modified all concatenation and removed extra deletion lines for cleanup. |
array_api_compat/numpy/_typing.py | Removed _all_ignore. |
array_api_compat/numpy/_aliases.py | Updated all assembly and removed _all_ignore for consistency. |
array_api_compat/dask/array/linalg.py | Removed _all_ignore and added a dir function returning all. |
array_api_compat/dask/array/fft.py | Removed _all_ignore and standardized dir implementation. |
array_api_compat/dask/array/_aliases.py | Removed _all_ignore. |
array_api_compat/cupy/_typing.py | Removed _all_ignore. |
array_api_compat/cupy/_aliases.py | Removed _all_ignore. |
array_api_compat/common/_linalg.py | Removed _all_ignore. |
array_api_compat/common/_helpers.py | Removed _all_ignore. |
array_api_compat/common/_aliases.py | Removed _all_ignore. |
|
||
NAMES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better version of this test could automatically scrape data-apis/array-api/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting that array-api-compat should add array-api as a git submodule, for testing only?
If so, do you agree that such a change is best left to a follow-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting that array-api-compat should add array-api as a git submodule, for testing only?
Definitely not.
If so, do you agree that such a change is best left to a follow-up?
Absolutely yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, the purpose of test_all
--- with all its considerable sins! --- was three-fold:
- make sure that the user-visible dir/all lists contain everything they should
- make sure that unwanted names do not bleed into the user-visible dir/all lists
- make sure that internal implementation modules
__all__
lists are sensible
This PR seems to work for the first item; the second one seems to still allow some strange things:
In [11]: import array_api_compat.numpy as anp
In [12]: "Final" in dir(anp)
Out[12]: True
In [13]: import numpy as np
In [14]: "Final" in dir(np)
Out[14]: False
For the third item, maybe we should somehow check that __all__
lists do not contain duplicate items? This would be useful for development (for one recent example, I'm not entirely sure if #317 does it right with __all__
lists; would be nice to have a test support for this)
I've heavily reworked the PR and fixed many issues where array-api-compat was hiding objects declared in the wrapped module.
|
#288 introduced
__dir__
, which completely neuteredtest_all
.Instead of reverting the change, this PR attempts to reinvent the test to be more useful.
CC @jorenham @ev-br