-
Notifications
You must be signed in to change notification settings - Fork 523
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
chore: use xp.take_along_axis
if Array API version >=2024.12
#4406
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.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.
Comments skipped due to low confidence (1)
deepmd/dpmodel/array_api.py:53
- Ensure that the new behavior introduced by
xp.take_along_axis
is covered by tests.
return xp.take_along_axis(arr, indices, axis=axis)
xp.take_along_axis
is Array API version >=2024.12xp.take_along_axis
if Array API version >=2024.12
📝 WalkthroughWalkthroughThe changes in this pull request introduce a new import statement for the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
deepmd/dpmodel/array_api.py (1)
51-53
: Consider centralizing array API version checksConsider moving the version check logic to a dedicated function or constant at the module level. This would:
- Avoid repeated version parsing
- Make it easier to update version requirements
- Provide a single point of control for array API compatibility
Example approach:
# At module level SUPPORTS_TAKE_ALONG_AXIS = Version(array_api_compat.array_namespace(...).__array_api_version__) >= Version("2024.12") # In function if SUPPORTS_TAKE_ALONG_AXIS: return xp.take_along_axis(arr, indices, axis=axis)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
deepmd/dpmodel/array_api.py
(2 hunks)
🔇 Additional comments (1)
deepmd/dpmodel/array_api.py (1)
5-7
: LGTM: Clean import of Version class
The addition of Version from packaging.version is appropriate for semantic version comparison.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #4406 +/- ##
=======================================
Coverage 84.64% 84.64%
=======================================
Files 614 614
Lines 57007 57010 +3
Branches 3486 3487 +1
=======================================
+ Hits 48254 48258 +4
- Misses 7627 7628 +1
+ Partials 1126 1124 -2 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
see: https://github.com/data-apis/array-api-strict/blob/d086c619a58f35c38240592ef994aa19ca7beebc/array_api_strict/_indexing_functions.py#L30-L39
Summary by CodeRabbit
xp_take_along_axis
function to utilize newer array API features when available, improving performance and functionality.