-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
MNT Add function to generate pytest IDs for yield_namespace_device_dtype_combinations
#31074
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
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.
Thanks for the PR!
Do you think we should use the ids
function in all the parametrized tests that use yield_namespace_device_dtype_combinations
?
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.
LGTM. There are probably many existing parametrized test that deserve to be updated. Feel free to do it as part of this PR (or not).
Yes I intend to do them in this PR, I was just not 100% on the implementation. Are we happy with the current implementation, even though it tries to import array-api-strict during test collection? Summary of possible options:
|
It seems to work fine locally when running:
You see that the tests are explicit about CPU_DEVICE vs device1 (part of the output below):
|
try: | ||
import array_api_strict | ||
except ImportError: | ||
return None |
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 mention the pytest doc link and mention that returning None doesn't change the default id if array-api-strict is not installed
return None | |
return |
Maybe also quickly mention the fact that this gives better ids for array-api-strict devices?
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.
I mentioned that None
means default but didn't add the link as it was long(er than char limit) and wasn't sure if it is needed, but happy to add if you wish.
yield_namespace_device_dtype_combinations
yield_namespace_device_dtype_combinations
Weird Debian32 CI failure build log is similar to the one seen in |
…type_combinations` (scikit-learn#31074)
…device_dtype_combinations` (scikit-learn#31074)" This reverts commit 6778690.
Reference Issues/PRs
closes #31042
What does this implement/fix? Explain your changes.
Adds a function that generates IDs pytest parametrization IDs for
yield_namespace_device_dtype_combinations
.The aim was to make it look the same as:
scikit-learn/sklearn/utils/_array_api.py
Lines 102 to 103 in 734245a
i.e.
I came up with the options:
array_api_strict.Device
- this is least brittle but does require that we try to importarray_api_strict
when collecting testsarray-api-strict.Device
__repr__
staying same.*\('([\w_]+)'\)
- to capture what is in brackets)Alternatively I could just use
return f"{param}"
but the ID would be long and slightlyconfusingdifficult to read:Any other comments?
cc @ogrisel @betatim