Skip to content

Conversation

@caic99
Copy link
Member

@caic99 caic99 commented Jun 17, 2025

This PR fixes the error in UT where the argument of xp.reshape should be a tuple, not a list.

Summary by CodeRabbit

  • Style
    • Standardized the use of tuple syntax for shape arguments in array reshaping operations throughout the application, replacing previous list-based syntax. This change ensures consistency and aligns with best practices for array manipulation. No functional behavior is affected.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

📝 Walkthrough

Walkthrough

The update standardizes array shape specifications by replacing list-based shape arguments with tuple-based ones in calls to xp.reshape, xp.tile, and related array operations across multiple modules. No logic, control flow, or public interfaces are changed.

Changes

File(s) Change Summary
deepmd/dpmodel/fitting/general_fitting.py Replaced list-style shape specifications with tuple-style in array reshaping and tiling calls.
deepmd/dpmodel/descriptor/dpa1.py Changed reshape shape argument from list [-1] to tuple (-1,).
deepmd/dpmodel/descriptor/dpa2.py Changed reshape shape argument from list [-1] to tuple (-1,).
deepmd/dpmodel/descriptor/dpa3.py Changed reshape shape argument from list [-1] to tuple (-1,) in two places.
deepmd/dpmodel/descriptor/se_t_tebd.py Changed reshape shape argument from list [-1] to tuple (-1,).
deepmd/dpmodel/fitting/polarizability_fitting.py Changed reshape shape argument from list [-1] to tuple (-1,) in two places.
deepmd/dpmodel/loss/ener.py Replaced list-style reshape arguments [-1] or [-1, ...] with tuple-style (-1,) or (-1, ...).
deepmd/dpmodel/model/transform_output.py Changed reshape argument from (mldims + [1] * len(...)) (list in parentheses) to explicit tuple.
deepmd/dpmodel/utils/env_mat_stat.py Changed reshape shape argument from list [-1, self.last_dim] to tuple (-1, self.last_dim).
deepmd/dpmodel/utils/exclude_mask.py Changed reshape shape argument from list [-1] to tuple (-1,).
deepmd/dpmodel/utils/neighbor_stat.py Changed reshape shape argument from list [nframes, -1, 3] to tuple (nframes, -1, 3) in two calls.
deepmd/dpmodel/utils/nlist.py Changed reshape shape argument from list [batch_size, -1, 3] to tuple (batch_size, -1, 3) in two calls.
deepmd/dpmodel/utils/region.py Changed reshape shape arguments from lists to tuples in to_face_distance function.
deepmd/dpmodel/array_api.py Changed construction of shape from list to tuple in xp_take_along_axis function.

Sequence Diagram(s)

No sequence diagram generated as the changes are limited to array shape syntax and do not affect control flow or feature logic.

Suggested reviewers

  • wanghan-iapcm
  • iProzd

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
deepmd/dpmodel/utils/env_mat_stat.py

No files to lint: exiting.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86ecb63 and 7a7eb60.

📒 Files selected for processing (1)
  • deepmd/dpmodel/utils/env_mat_stat.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • deepmd/dpmodel/utils/env_mat_stat.py
⏰ Context from checks skipped due to timeout of 90000ms (29)
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Analyze (python)
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Test C++ (true)
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C++ (cpu, cpu)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build C library (2.14, >=2.5.0rc0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Test C++ (false)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
deepmd/dpmodel/fitting/general_fitting.py (4)

415-416: Consider broadcast_to to avoid the tile memory-duplication

xp.tile(xp.reshape(fparam, (nf, 1, self.numb_fparam)), (1, nloc, 1)) materialises a full (nf, nloc, numb_fparam) array.
With the same semantics you can keep everything as a lightweight broadcasted view:

-fparam = xp.tile(
-    xp.reshape(fparam, (nf, 1, self.numb_fparam)), (1, nloc, 1)
-)
+fparam = xp.broadcast_to(
+    xp.reshape(fparam, (nf, 1, self.numb_fparam)),
+    (nf, nloc, self.numb_fparam),
+)

Reduces both peak memory and unnecessary copies.


449-450: Same tile caveat as above for case_embd

case_embd = xp.tile(
    xp.reshape(self.case_embd[...], (1, 1, -1)), (nf, nloc, 1)
)

xp.broadcast_to would achieve the same broadcast semantics without allocating the repeated data:

-case_embd = xp.tile(
-    xp.reshape(self.case_embd[...], (1, 1, -1)), (nf, nloc, 1)
-)
+case_embd = xp.broadcast_to(
+    xp.reshape(self.case_embd[...], (1, 1, -1)),
+    (nf, nloc, self.dim_case_embd),
+)

Minor, but can matter for large systems.


468-469: Mask construction: use boolean broadcasting instead of tile

The current pattern duplicates a (nf, nloc) boolean mask net_dim_out times:

mask = xp.tile(xp.reshape((atype == type_i), (nf, nloc, 1)), (1, 1, net_dim_out))

This can be simplified and zero-copy by relying on implicit broadcasting:

-mask = xp.tile(
-    xp.reshape((atype == type_i), (nf, nloc, 1)), (1, 1, net_dim_out)
-)
+mask = xp.reshape((atype == type_i), (nf, nloc, 1))

All later xp.where(mask, …) calls will automatically broadcast the singleton dimension across net_dim_out.


488-492: Type-safety check for atype before xp.take

xp.take requires atype to be an integer tensor. If callers accidentally pass a float array the code will silently cast on some back-ends but raise on others. Consider enforcing:

if not xp.issubdtype(atype.dtype, xp.integer):
    raise TypeError("`atype` must contain integer type indices")

Not a blocker, but will make failures deterministic across back-ends.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b494a0d and 005783f.

📒 Files selected for processing (1)
  • deepmd/dpmodel/fitting/general_fitting.py (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (29)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Build C library (2.14, >=2.5.0rc0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build C++ (cpu, cpu)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Analyze (python)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Test C++ (true)
🔇 Additional comments (1)
deepmd/dpmodel/fitting/general_fitting.py (1)

434-435: LGTM – shape clarification

Switching to a tuple literal in xp.reshape(aparam, (nf, nloc, self.numb_aparam)) keeps the behaviour intact and aligns with the Array-API spec.

@njzjz njzjz changed the base branch from master to devel June 17, 2025 07:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
deepmd/dpmodel/utils/exclude_mask.py (1)

55-57: Align reshape-API usage across the class

You correctly switched the runtime reshape to use a tuple, but the class-level cache created in __init__ still uses the old list style (reshape([-1]), line 26). Small, but it leaves an inconsistency in the public attribute type_mask.

-        self.type_mask = type_mask.reshape([-1])
+        # Keep reshape syntax consistent with the rest of the codebase
+        self.type_mask = type_mask.reshape((-1,))
deepmd/dpmodel/utils/region.py (1)

95-97: Prefer unpacking over list-conversion for clearer intent

tuple(list(cshape[:-2]) + [3]) allocates an intermediate list every call. You can achieve the same shape without the extra object and with simpler intent:

-    return xp.reshape(dist, tuple(list(cshape[:-2]) + [3]))  # noqa:RUF005
+    return xp.reshape(dist, (*cshape[:-2], 3))

Besides the tiny performance gain, using the star-unpack pattern is more idiomatic and easier to read.

deepmd/dpmodel/fitting/polarizability_fitting.py (1)

314-322: Minor API-compatibility concern regarding xp.astype

While untouched by this diff, note that array_api_compat namespaces do not guarantee a top-level astype function (NumPy provides np.asarray(..., dtype=...) instead). If any backend other than NumPy is used, this may raise. Consider switching to

xp.asarray(self.constant_matrix, dtype=out.dtype)

for maximum array-API compliance.

deepmd/dpmodel/loss/ener.py (1)

239-243: Minor style consistency

To stay uniform with the rest of the edits, you may also convert the shape in this block to tuples:

-            drdq_reshape = xp.reshape(
-                drdq, (-1, natoms[0] * 3, self.numb_generalized_coord)
-            )
+            drdq_reshape = xp.reshape(
+                drdq, (-1, natoms[0] * 3, self.numb_generalized_coord)
+            )

(Not critical—just style.)

deepmd/dpmodel/model/transform_output.py (1)

98-112: Consider avoiding shadowing of mapping for clarity

Inside the for-loop, mapping is reassigned twice (reshape then tile), while the original array is kept as mapping_. Although functionally correct, this shadowing can be confusing and error-prone in future edits.

-            mapping = xp.reshape(
-                mapping, tuple(mldims + [1] * len(derv_r_ext_dims))
-            )
+            mapping_reshaped = xp.reshape(
+                mapping, tuple(mldims + [1] * len(derv_r_ext_dims))
+            )
 ...
-            mapping = xp.tile(mapping, [1] * len(mldims) + derv_r_ext_dims)
+            mapping_tiled = xp.tile(
+                mapping_reshaped, [1] * len(mldims) + derv_r_ext_dims
+            )

Renaming the intermediate tensors makes the intent explicit and prevents accidental misuse later in the block (and in the c_differentiable section).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 005783f and 5acb937.

📒 Files selected for processing (12)
  • deepmd/dpmodel/descriptor/dpa1.py (1 hunks)
  • deepmd/dpmodel/descriptor/dpa2.py (1 hunks)
  • deepmd/dpmodel/descriptor/dpa3.py (1 hunks)
  • deepmd/dpmodel/descriptor/se_t_tebd.py (1 hunks)
  • deepmd/dpmodel/fitting/polarizability_fitting.py (2 hunks)
  • deepmd/dpmodel/loss/ener.py (5 hunks)
  • deepmd/dpmodel/model/transform_output.py (1 hunks)
  • deepmd/dpmodel/utils/env_mat_stat.py (1 hunks)
  • deepmd/dpmodel/utils/exclude_mask.py (1 hunks)
  • deepmd/dpmodel/utils/neighbor_stat.py (1 hunks)
  • deepmd/dpmodel/utils/nlist.py (1 hunks)
  • deepmd/dpmodel/utils/region.py (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • deepmd/dpmodel/utils/env_mat_stat.py
  • deepmd/dpmodel/descriptor/dpa2.py
  • deepmd/dpmodel/descriptor/dpa1.py
  • deepmd/dpmodel/utils/neighbor_stat.py
  • deepmd/dpmodel/descriptor/se_t_tebd.py
  • deepmd/dpmodel/utils/nlist.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
deepmd/dpmodel/loss/ener.py (1)
deepmd/dpmodel/loss/loss.py (1)
  • display_if_exist (38-56)
⏰ Context from checks skipped due to timeout of 90000ms (24)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Test C++ (true)
  • GitHub Check: Build C library (2.14, >=2.5.0rc0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Analyze (c-cpp)
🔇 Additional comments (6)
deepmd/dpmodel/fitting/polarizability_fitting.py (1)

290-294: Change looks good

Tuple reshape matches the PR objective and the rest of the codebase. No further issues spotted.

deepmd/dpmodel/loss/ener.py (2)

135-147: xp.norm is not part of the Array-API

The new tuple reshapes are fine, but line 143 still calls xp.norm, which is outside the official array-API spec and will fail for backends that expose only the standard namespace. Use xp.linalg.vector_norm (or xp.linalg.norm) instead.

-            norm_f = xp.reshape(xp.norm(force_hat_3, axis=1), (-1, 1)) + self.relative_f
+            norm_f = xp.reshape(
+                xp.linalg.vector_norm(force_hat_3, axis=1), (-1, 1)
+            ) + self.relative_f

186-189: Tuple reshape LGTM

The huber-loss branch now uses tuple style consistently—good catch.

deepmd/dpmodel/descriptor/dpa3.py (2)

563-567: Reshape update approved

Tuple reshape is correct and keeps the backend-agnostic indexing intact. No further issues.


569-572: Same as above

Consistent tuple usage—looks good.

deepmd/dpmodel/model/transform_output.py (1)

103-105: Correct use of tuple for xp.reshape 👍

Switching the second argument of xp.reshape from a bare list to an explicit tuple(...) fixes compatibility issues with back-ends (e.g. some JAX / CuPy versions reject list shapes). No further action needed.

@wanghan-iapcm wanghan-iapcm requested a review from njzjz June 17, 2025 09:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
deepmd/dpmodel/array_api.py (1)

61-64: Build the target shape without the intermediate list allocation

arr.shape is already a tuple; turning it into a list, mutating, and then converting back introduces an avoidable copy and an extra mutation step.

-    shape = list(arr.shape)
-    shape.pop(-1)
-    shape = (*shape, n)
+    # keep it tuple throughout
+    shape = (*arr.shape[:-1], n)

This single-expression version is clearer, avoids temporary objects, and remains backend-agnostic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5acb937 and ca9ae69.

📒 Files selected for processing (1)
  • deepmd/dpmodel/array_api.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (29)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test C++ (true)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build C library (2.14, >=2.5.0rc0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Analyze (python)
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C++ (cpu, cpu)

@caic99 caic99 requested a review from Copilot June 17, 2025 09:31
Copy link
Contributor

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 standardizes array shape specifications in reshape and take operations by using tuples instead of lists, improving style consistency without altering functionality.

  • Consistently replace list-based shape arguments in xp.reshape and xp.take with tuple-based arguments.
  • Minor refactoring in deepmd/dpmodel/array_api.py to use tuple unpacking for shape construction.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
deepmd/dpmodel/utils/region.py Use tuple for reshape shapes
deepmd/dpmodel/utils/nlist.py Use tuple for reshape shapes
deepmd/dpmodel/utils/neighbor_stat.py Use tuple for reshape shapes
deepmd/dpmodel/utils/exclude_mask.py Use tuple for reshape shapes in xp.take
deepmd/dpmodel/utils/env_mat_stat.py Use tuple for reshape shapes
deepmd/dpmodel/model/transform_output.py Use tuple for multi-dimensional reshape
deepmd/dpmodel/loss/ener.py Use tuple for reshape shapes throughout loss logic
deepmd/dpmodel/fitting/polarizability_fitting.py Use tuple for reshape in scaling operations
deepmd/dpmodel/fitting/general_fitting.py Use tuple for reshape in parameter tiling
deepmd/dpmodel/descriptor/se_t_tebd.py Use tuple for reshape in type embedding expansion
deepmd/dpmodel/descriptor/dpa3.py Use tuple for reshape in node embedding expansion
deepmd/dpmodel/descriptor/dpa2.py Use tuple for reshape in generic embedding
deepmd/dpmodel/descriptor/dpa1.py Use tuple for reshape in atomic embedding
deepmd/dpmodel/array_api.py Use tuple unpacking for dynamic shape construction

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.79%. Comparing base (ab6e300) to head (7a7eb60).
⚠️ Report is 92 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/dpmodel/loss/ener.py 53.84% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4808      +/-   ##
==========================================
- Coverage   84.80%   84.79%   -0.01%     
==========================================
  Files         698      698              
  Lines       67798    67816      +18     
  Branches     3542     3541       -1     
==========================================
+ Hits        57494    57503       +9     
- Misses       9171     9177       +6     
- Partials     1133     1136       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@caic99 caic99 requested a review from iProzd June 18, 2025 05:23
@njzjz njzjz added this pull request to the merge queue Jun 18, 2025
Merged via the queue into deepmodeling:devel with commit 1dc5b04 Jun 18, 2025
72 of 74 checks passed
ChiahsinChu pushed a commit to ChiahsinChu/deepmd-kit that referenced this pull request Dec 17, 2025
This PR fixes the error in UT where the argument of `xp.reshape` should
be a tuple, not a list.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Style**
- Standardized the use of tuple syntax for shape arguments in array
reshaping operations throughout the application, replacing previous
list-based syntax. This change ensures consistency and aligns with best
practices for array manipulation. No functional behavior is affected.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants