MAINT: __array_namespace_info__ docstrings tweaks#300
Merged
ev-br merged 3 commits intodata-apis:mainfrom Apr 15, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR clarifies the output of array_namespace_info().default_device() across various array API compatibility modules by updating type annotations and enhancing docstrings.
- Updated type annotations from str to Device for default_device, devices, and related parameters.
- Added Notes sections in docstrings for Torch and CuPy to explain the static and dynamic behavior of device creation.
- Updated internal comments in the common aliases to reflect consistent usage with Dask.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| array_api_compat/torch/_info.py | Updated type annotations and enhanced default_device documentation. |
| array_api_compat/numpy/_info.py | Changed return type annotations to Device for default_device and devices. |
| array_api_compat/dask/array/_info.py | Changed type annotations to Device for default_device and devices. |
| array_api_compat/cupy/_info.py | Updated default_device docs and type annotations with additional Notes. |
| array_api_compat/common/_aliases.py | Modified comment to include Dask in the description. |
Comments suppressed due to low confidence (2)
array_api_compat/torch/_info.py:112
- [nitpick] The example output in the default_device docstring uses 'device(type='cpu')' which may not clearly reflect the actual representation returned by torch.device('cpu'). Consider aligning the example with the returned object's format for consistency.
device(type='cpu')
array_api_compat/cupy/_info.py:128
- [nitpick] The example output in the default_device docstring shows 'Device(0)' while the function returns cuda.Device(0). It may help to clarify or adjust the example so that it accurately reflects the returned object's representation.
Device(0)
2c87d36 to
7e4d303
Compare
Contributor
Author
|
CI failure is unrelated. |
default_device output__array_namespace_info__ docstrings tweaks
Member
|
LGTM thank you @crusaderky |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__array_namespace_info__().default_device()output.Read controversy at Clarify definitions of "default device" and "current device" array-api#835.
_infomodules