Skip to content

MAINT: __array_namespace_info__ docstrings tweaks #300

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

Merged
merged 3 commits into from
Apr 15, 2025

Conversation

crusaderky
Copy link
Contributor

@crusaderky crusaderky commented Apr 3, 2025

@Copilot Copilot bot review requested due to automatic review settings April 3, 2025 10:50
Copy link
Contributor

@Copilot Copilot AI left a 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 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)

@crusaderky
Copy link
Contributor Author

CI failure is unrelated.

@crusaderky crusaderky changed the title MAINT: clarify default_device output MAINT: __array_namespace_info__ docstrings tweaks Apr 11, 2025
@ev-br ev-br merged commit d743dc1 into data-apis:main Apr 15, 2025
40 checks passed
@ev-br
Copy link
Member

ev-br commented Apr 15, 2025

LGTM thank you @crusaderky

@ev-br ev-br added this to the 1.12 milestone Apr 15, 2025
@crusaderky crusaderky deleted the default_device branch April 15, 2025 12:45
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