Skip to content

Conversation

@OutisLi
Copy link
Collaborator

@OutisLi OutisLi commented Nov 13, 2025

Summary

  • add a regression test that reproduces the original atom-type remapping failure when the training system contains fewer atom types than the provided type_map
  • ensure the fix from commit 4ec0437 remains covered going forward

Summary by CodeRabbit

  • Tests
    • Added unit tests for DeepmdData that validate atom-type remapping, handling of unused types, and correct loading/formatting of type arrays.

Copilot AI review requested due to automatic review settings November 13, 2025 11:40
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 adds a regression test to ensure that atom type remapping works correctly when the training system contains fewer atom types than the provided type_map. The test verifies the fix from commit 4ec0437.

Key changes:

  • Adds a new test file test_deepmd_data.py with regression test for atom type remapping functionality
  • Tests the scenario where a system has atoms of types O and H, but the type_map includes an unused Si type
  • Verifies correct remapping when loading data with a different type_map ordering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

📝 Walkthrough

Walkthrough

Adds a new unit test module that creates a temporary DeepMD dataset, writes atom type and type map files, and verifies DeepmdData's atom-type remapping, stored internal type_map, and _load_set output shape/content.

Changes

Cohort / File(s) Change Summary
New test module for DeepmdData type mapping
source/tests/common/test_deepmd_data.py
Adds TestDeepmdDataTypeMap with setUp/tearDown creating a temporary dataset (set.000, type.raw, type_map.raw, coord.npy, box.npy), writes atom types and a 3-entry type map, instantiates DeepmdData with a custom type_map containing unused types, and asserts remapped atom_type, internal type_map, and _load_set output match expected values.

Sequence Diagram(s)

sequenceDiagram
    participant T as TestCase
    participant FS as FileSystem (temp dataset)
    participant D as DeepmdData

    T->>FS: write type.raw, type_map.raw, coord.npy, box.npy
    T->>D: instantiate DeepmdData(type_map=custom_map)
    D->>FS: read type_map.raw (if used) and type.raw
    D->>D: remap atom types using provided type_map / idx_map
    D-->>T: expose remapped atom_type and internal type_map
    T->>D: call _load_set("set.000")
    D->>FS: read set files (type, coord, box)
    D-->>T: return loaded set dict with "type" array (2D broadcasted via idx_map)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single new test file; straightforward filesystem setup and assertions.
  • Pay attention to assertions around remapping and expected broadcasting behavior.

Possibly related PRs

Suggested reviewers

  • iProzd

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(common): add regression for atom type remap' is directly related to the main change - a new regression test for atom type remapping logic in the DeepmdData class.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 0f3df73 and 5dcd916.

📒 Files selected for processing (1)
  • source/tests/common/test_deepmd_data.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/tests/common/test_deepmd_data.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Build C++ (cuda120, cuda)
  • GitHub Check: Build C++ (clang, clang)
  • GitHub Check: Build C++ (cuda, cuda)
  • GitHub Check: Build C++ (cpu, cpu)
  • GitHub Check: Build C++ (rocm, rocm)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Test C++ (true)
  • GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Build wheels for cp311-macosx_arm64
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (c-cpp)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.19%. Comparing base (87cb6ef) to head (5dcd916).
⚠️ Report is 2 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #5050   +/-   ##
=======================================
  Coverage   84.18%   84.19%           
=======================================
  Files         709      709           
  Lines       70215    70216    +1     
  Branches     3620     3618    -2     
=======================================
+ Hits        59114    59115    +1     
- Misses       9934     9935    +1     
+ Partials     1167     1166    -1     

☔ 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.

@OutisLi OutisLi requested review from iProzd and njzjz November 13, 2025 15:14
@OutisLi OutisLi requested a review from njzjz November 14, 2025 02:33
@njzjz njzjz added this pull request to the merge queue Nov 14, 2025
Merged via the queue into deepmodeling:devel with commit 1ccc57d Nov 14, 2025
60 checks passed
@OutisLi OutisLi deleted the pr/load_test branch November 14, 2025 10:14
ChiahsinChu pushed a commit to ChiahsinChu/deepmd-kit that referenced this pull request Dec 17, 2025
## Summary
- add a regression test that reproduces the original atom-type remapping
failure when the training system contains fewer atom types than the
provided type_map
- ensure the fix from commit 4ec0437
remains covered going forward

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

* **Tests**
* Added unit tests for DeepmdData that validate atom-type remapping,
handling of unused types, and correct loading/formatting of type arrays.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants